Map toolbar: long-press + flyout for line, rectangle, circle geometry helpers#11
Draft
tordans wants to merge 2 commits into
Draft
Map toolbar: long-press + flyout for line, rectangle, circle geometry helpers#11tordans wants to merge 2 commits into
tordans wants to merge 2 commits into
Conversation
Long-press the map toolbar + button (≥0.5s) to open an action sheet with Line, Rectangle, and Circle tools. Short press behavior is unchanged. Each tool enters a dedicated map edit mode with rubber-band preview tied to the crosshair. Rectangle and circle math live in GeometryDrawMath with unit tests. Line mode reuses extendSelectedWay via successive crosshair taps. Co-authored-by: Tobias <t@tobiasjordans.de>
c4f3c0f to
ed41fd1
Compare
- Route map taps through geometryDrawHandleMapTap: hit object to cancel/select, empty map tap places vertex at crosshair - Cancel geometry mode on long-press selection and on undo - Group rectangle/circle commit into single undo step; rollback group on error - Update flash hints to describe tap-object-to-cancel Co-authored-by: Tobias <t@tobiasjordans.de>
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.
Problem
As a mapper, I want to long-press the + toolbar button and choose Line, Rectangle, or Circle so I can start structured way/area work on the map—without only dropping isolated nodes via a single short tap.
Today, short tap on + adds a node at the crosshair (same as right-click). Long-press on + previously did nothing useful after 0.5s. The display/layers button already uses a long-press action sheet; + should follow that pattern for geometry tools.
User interaction
Short press + (unchanged)
rightClickat crosshair → existingaddNode/ way-extension behavior.Long press + (new)
UIAlertControlleraction sheet:addNodeButton(iPad).Dedicated map edit mode
Choosing a tool enters a geometry mode separate from normal single-tap node placement:
extendSelectedWay/addNodeVertices are placed at
viewPort.screenCenterPoint()(crosshair), not at the finger location—consistent with how + targets the crosshair.Live preview (rubber band)
Orange dashed
CAShapeLayeronEditorMapLayer, updated on map pan/zoom viamapTransform.onChange:Cancel / finish
selectObjectAtPointcallscancelGeometryDraw()), or Undo for partial edits.extendSelectedWayjoin logic.Hold + while tapping map
If the user holds + and taps the map (existing gesture), geometry mode routes to
geometryDrawTap(at: crosshair)instead ofaddNode(at: finger).Implementation notes (by Cursor)
Phase A — UI (
MainViewController)plusButtonLongPressHandler: on.ended, if duration ≥ 0.5s and touch inside button →presentGeometryDrawFlyout().displayButtonLongPressHandler()pattern.Phase B — Line mode
beginGeometryDraw(.line)places pushpin at crosshair; each map tap callsaddNode(at:)(reusesextendSelectedWay).Phase C — Rectangle / circle
GeometryDrawMath.swift— pure math (testable):rectangleCorners(cornerA:cornerB:thirdPointHint:),circleRing(diameterA:diameterB:), lat/lon plane helpers vialat2latp/latp2lat.EditorMapLayer+GeometryDraw.swift— state (geometryDrawTool,geometryDrawFixedCorners, preview layer), tap handlers,commitClosedWayfor rectangle/circle.geometryDrawPreviewTokensoonChange.unsubscribedoes not remove the layer’s main layout observer.Map routing (
MapView)handleTapGesture: ifisGeometryDrawActive→geometryDrawTap(at: screenCenter).rightClick: same when geometry mode active.beginGeometryDraw(_:)entry point from flyout.Tests
GeometryDrawMathTestCase: right angles on rectangle, perpendicular projection, circle radius, rubber-band polyline.Files changed
MainViewController.swiftMapView.swiftbeginGeometryDrawEditorMapLayer.swiftEditorMapLayer+GeometryDraw.swiftEditorMapLayer+Edit.swiftGeometryDrawMath.swiftGeometryDrawMathTestCase.swiftproject.pbxprojTesting notes (by @tordans)
CAShapeLayer.