Skip to content

MapControl floating map toolbar plugin - #238

Open
CarsonDavis wants to merge 1 commit into
feat/mapcontrol-corefrom
feat/mapcontrol-toolbar
Open

MapControl floating map toolbar plugin#238
CarsonDavis wants to merge 1 commit into
feat/mapcontrol-corefrom
feat/mapcontrol-toolbar

Conversation

@CarsonDavis

Copy link
Copy Markdown
Collaborator

Description

Second half of the split of #115 (by @BhattaraiSijan) — the MapControl plugin itself, stacked on #237, which provides the core APIs it consumes. All 27 files are byte-identical to the original branch; commits are attributed to the original author. Do not merge before #237.

Closes #98.

Adds MapControl, a floating toolbar over the map with four features, each enabled/disabled per-mission from the Configure page. The plugin is bus-only: the React component is MMGIS-independent and a thin wrapper translates its callbacks into mmgisAPI calls (all provided by #237).

Geocode search

On each keystroke we hit the Nominatim API with the URL-encoded query — debounced 300ms, only firing for queries ≥2 chars, limit=5. No API key or backend (public endpoint). On selecting a result we reorder Nominatim's bbox into Leaflet order, fly to it via map:fitBounds, and drop a pin via map:createLayer.

Basemap switching

Lists the styles from msv.basemap.styles[] (or provider defaults) via map:getBasemapStyles and switches with map:setBasemap — deck.gl swaps the vector style in place; Leaflet rebuilds the tile layer.

Measure

Subscribes to map:click / map:mousemove, collects two points, and draws the line + endpoints as a vector layer via map:createLayer. Distance is computed with Turf; the label is positioned by projecting the segment midpoint via map:latLngToContainerPoint.

Zoom

map:zoomIn / map:zoomOut, clamped to the engine's min/max zoom.

Dependency on #90 (imapengine-drawing)

Vector overlays (the measure line and the search pin) are drawn via map:createLayer / map:removeLayer, which are provided by #90. Until #90 merges these two features no-op (guarded, no crash); the rest of the plugin is self-contained. See #115 for the full rationale on why this uses map:createLayer rather than its own overlay channels.

Known limitation / future work

MapControl is a floating overlay, not a docked panel, so it bypasses the normal panel-mount path: it self-mounts at bundle load by polling for the map container and rendering into a position:fixed layer on document.body. This works but should be replaced by a proper "floating tool" mount path in the Modern layout so overlays don't have to self-mount.

Testing

Unit suite and npm run build pass on the stacked branch. Manual checks (from #115):

  • Toggle each of the four features from the Configure page; confirm each appears/hides.
  • Test on both a Leaflet and a deck.gl mission.
  • Basemap switcher: confirm the list populates (it retries until the map registers its handlers) and switching restyles the map on both engines.
  • Search: type a place, confirm results, select one, confirm fly-to + pin.
  • Measure: click two points, confirm line + distance label. (Requires feat(core): drawing primitives + overlay + bus surface on IMapEngine #90 for the overlay.)
  • Zoom: confirm in/out and that it stops at min/max.

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.

2 participants