Skip to content

feat(core): drawing primitives + overlay + bus surface on IMapEngine#90

Open
BhattaraiSijan wants to merge 6 commits into
developmentfrom
feat/imapengine-drawing
Open

feat(core): drawing primitives + overlay + bus surface on IMapEngine#90
BhattaraiSijan wants to merge 6 commits into
developmentfrom
feat/imapengine-drawing

Conversation

@BhattaraiSijan
Copy link
Copy Markdown
Collaborator

@BhattaraiSijan BhattaraiSijan commented May 20, 2026

Adds to the core map engine + plugin bus. Consumed downstream by a follow-up AOI plugin PR

Drawing

  • IMapEngine: 4 methods (enableDrawing / disableDrawing / finishDrawing / isDrawing) + 4 events (drawstart / drawvertex / drawcomplete / drawcancel).
  • types/events.ts: 6 types — DrawShape, DrawingOptions, and 4 event payload interfaces.
  • Leaflet adapter: wraps leaflet-draw + 2 helpers in LeafletHelpers.ts (leafletDrawnLayerToFeature, extractDrawVertices).
  • DeckGL adapter: hand-rolled state machine + 3 helpers in DeckGLHelpers.ts (buildDrawnFeature, buildPreviewFeature, 32-segment circle approximation + haversine for radius).

Anchored HTML overlays

  • IMapEngine: 2 methods (addOverlay / removeOverlay) + 1 type (OverlayOptions).
  • Leaflet adapter: backed by L.marker + L.divIcon (reposition is native).
  • DeckGL adapter: DOM node appended to the container, reprojected on move / moveend.

Bus surface in Map_.js

  • Refactored 6 existing providers (map:getCenter / getBounds / getZoom / setView / fitBounds / panTo) from Map_.map.*engine.* so they're engine-agnostic.
  • Added 9 providers: drawing (4) + layers (createLayer / removeLayer / hasLayer, wrapping pre-existing engine methods) + overlays (2).
  • Added 6 engine → bus re-emits: 4 drawing events + move / moveend.

MapEngines/index.ts exports the new types.

Follow-up: consumer plugin PR

The AOI plugin PR (feat/draw-aoi-plugin) consumes this surface:

  • mmgisAPI.request('map:enableDrawing', ...) for the draw flow.
  • mmgisAPI.on('map:drawcomplete', ...) to receive the finalised feature.
  • mmgisAPI.request('map:createLayer', ...) to render the selected AOI on the map.
  • mmgisAPI.request('map:addOverlay', ...) for the action tooltip.

No further core changes are required for that PR to ship.

Discussion

  • **DeckGL draw is hand-rolled ** vs Leaflet's thin wrapper around leaflet-draw. Maybe use library like terradraw for deck.gl drawing? Experimented with editable-layers, but it did not work.
  • Branch history includes the editable-layers experiment + revert (1c9b1751 / 40c0a899). Recommend squash-and-merge to keep development's log clean.

Closes: #88

Test plan

  • Polygon / rectangle / circle draw flow in Leaflet and DeckGL overlay mode — verified manually with the AOI plugin on feat/draw-aoi-plugin.
  • AOI plugin tooltip mounted via map:addOverlay, removed via map:removeOverlay.
  • map:drawcomplete payload reaches a consumer plugin through the bus.
  • npx tsc --noEmit exits 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Develop core APIs and handlers for AOI/Drawing Plugin

1 participant