-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't avoid snap near line #2
Comments
Hi, you can actually control the snapping behavior using Boolean option draw.options.snap = false; there's an example in the docs directory showing this. but you're right I should've mentioned this control option and the on a side note, there's also an option const draw = new MapboxDraw({
...
snapOptions: {
snapPx: 15,
snapToMidPoints: true,
},
}); |
Well, yes - but that just disables snapping entirely, which isn't what I want.
Yes, I noticed that - but that doesn't really solve the issue either. The more I think about it, the more I think this is incorrect behaviour - hovering the mouse near the midpoint of a line shouldn't cause any special snapping to happen if snapToMidpoints is false (as it is in my case). |
Ah, I thought you can disable it and enable it later.
setting mapbox-gl-draw-snap-mode/src/utils/index.js Line 246 in 86f7a5d
would you think reducing this (and make it dynamic) would solve this problem? |
@stevage I tested changing this MI5bivXq6G.mp4
so, I updated the package on snapOptions: {
snapVertexPriorityDistance: 0.0025, // defaults to 1.25
} |
I'm to be honest I'm really confused with the relationship between
Since the behaviour of snapVertexPriorityDistance is subtle, hard to explain, and uses obscure units (what are they?), I'd suggest just picking a good default setting and leaving it at that. I don't know if there is a bug or I'm not understanding what |
Sorry for the late response, you're assuming on the other hand, the
I think its behavior is not that subtle, it can be dynamically (using a range element for example) or programmatically (based on zoom level I think) controlled so that the snaping is always acting as desired. |
First - thanks, this library is amazing. I have worked snapping in the past and it's a real pain!
I ran into a bit of an issue attempting to draw polygons. Here you can see I am attempting to trace the raster.
Screen.Recording.2021-08-10.at.4.21.47.PM.mov
The point I am trying to create is not near a vertex, so I don't expect it to snap. But it seems it detects that my point is near the line, and snaps to the nearest vertex.
I'm not sure if this is a bug or just surprising behaviour that should maybe be avoidable with an option.
(I have just discovered that holding Option temporarily prevents snapping, which is a fine workaround for me. That should probably be documented, too...)
The text was updated successfully, but these errors were encountered: