Add vertex-snap mode: Shift+Option+drag snaps to vertices with highlights - #1007
Open
chriswhong wants to merge 6 commits into
Open
Add vertex-snap mode: Shift+Option+drag snaps to vertices with highlights#1007chriswhong wants to merge 6 commits into
chriswhong wants to merge 6 commits into
Conversation
chriswhong
force-pushed
the
cw/vertex-snap-mode
branch
from
June 11, 2026 15:38
0f5c94f to
0b474cc
Compare
AndrewSepic
reviewed
Jun 15, 2026
Contributor
There was a problem hiding this comment.
This works with existing polygons, but does not work when creating a new polygon. ie: creating a new Polygon adjacent to an existing one, does not have the ability to vertex snap, (although snapping to edges does work). I think this should behaviour should be the same whether you are working on an existing feature or creating a new feature.
AndrewSepic
requested changes
Jun 15, 2026
chriswhong
force-pushed
the
cw/vertex-snap-mode
branch
from
June 24, 2026 21:07
c21809e to
b0ae9b5
Compare
Contributor
Author
|
Snapping is now working when drawing new linestrings and polygons, and I also made sure that it also works when when drawing the initial vertex of a linestring or polygon, or when drawing a point. |
AndrewSepic
previously approved these changes
Jun 25, 2026
AndrewSepic
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the fix! Looking good. Left a small comment to make sure the change was intentional.
AndrewSepic
reviewed
Jun 25, 2026
typeof dragTargetRef.current === 'string' was always false because RawId is Opaque<number, 'RawId'>. The draggingVertex check never passed, so highlights never appeared on keydown. Fix mirrors the move handler: use !Array.isArray to distinguish a single-vertex drag (RawId) from a multi-feature drag (string[]). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix line.ts snapping to exclude the feature being drawn (missing excludeFeatureId) - Add vertex-snap visual feedback (highlight circles) during drawing for both line and polygon modes - Alt+Shift during drawing now snaps to vertices only (matching edit mode behavior) instead of conflicting with direction locking - Update mode hints to document Option+Shift vertex snapping and only show snap hint for features with vertices Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Snap first vertex of new lines and polygons when Alt is held - Show vertex snap highlights before first click in line/polygon draw modes - Add full snap support (Alt/Alt+Shift) when drawing points Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
chriswhong
force-pushed
the
cw/vertex-snap-mode
branch
from
July 15, 2026 13:58
2eb2cc6 to
02ce652
Compare
Vertex highlights should only appear when holding Option+Shift, matching the behavior when dragging a vertex from an existing feature. Previously, holding Option alone while drawing a line, polygon, or point would show the vertex-snap overlay. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improves snapping by providing a modifier key for snapping to vertices only, not edges. Highlights vertices on nearby features.
More on the use case: I often need to hand-draw a polygon adjacent to an existing polygon, and want them to share vertices. Snapping is very helpful here, but depending on zoom the current snapping feature sometimes gets you close but not quite on the adjacent feature's vertex. There are also situations where many vertices make a smooth curve and it may not be clear where the vertices are, so showing them in a subtle way is helpful for knowing what needs to be added to a new polygon.
Implementation
EphemeralEditingStateVertexSnaptype instate/jotai.tscarries vertex positions to the render layergetSnappingCoordinatesinutils.tsaccepts averticesOnlyflag — when true, snaps to the nearest coordinate vertex using turfdistance()rather thannearestPointOnLine()getNearbyVerticesinutils.tsqueries a wider 80px search box and collects all vertices from every nearby featureScatterplotLayerinpmap/index.tsrenders the amber highlight circles when ephemeral state is'vertex-snap'uphandler)Test plan
🤖 Generated with Claude Code