Skip to content

Emit feature:click on the bus for every vector feature click - #292

Open
BhattaraiSijan wants to merge 8 commits into
developmentfrom
feat/feature-click-event
Open

Emit feature:click on the bus for every vector feature click#292
BhattaraiSijan wants to merge 8 commits into
developmentfrom
feat/feature-click-event

Conversation

@BhattaraiSijan

@BhattaraiSijan BhattaraiSijan commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a single generic bus event, feature:click — fired for every click on a vector feature, on any layer type (classic GeoJSON, vector tile, engine-adapter) and either engine. Payload: { feature, layerName (uuid), latlng, pixel }.

Unlike feature:active it carries no selection semantics and stays independent of the legacy Kinds/Info flow. Unlike map:featureClick it never fires for empty-space clicks and covers mission-config layers, not just adapter-created ones. All three click pipelines in Map_.js funnel into one emit function, so the name and payload are defined in exactly one place.

Documented in the Event-Bus API page. First consumer is the FetchTimeseries plugin (see merge order below).

Known edge

A single physical click on a classic mission feature that also sits over an adapter-created layer emits two feature:click events (one per pipeline, different layerNames). Contained in practice — consumers filter by layer — but worth knowing when debugging.

Merge order

  1. this PRdevelopment
  2. SeriesChart: chart-series contract and single-variable chart plugin #293 SeriesChart (independent of this one)
  3. FetchTimeseries: feature clicks to chart-series events #294 FetchTimeseries (needs this event at runtime; no compile dependency)

Testing

Manual: window.mmgisAPI.on('feature:click', console.log) then click features on a Leaflet-classic mission layer, a vectortile layer, and a deck.gl GeoJsonLayer — one event each, identical shape. Full unit suite green (1040).

@BhattaraiSijan

Copy link
Copy Markdown
Collaborator Author

Addressed the review findings on this PR:

  • Two quick clicks on a vector-tile layer could emit feature A with B's location — the debounce now snapshots the clicked feature at click time so the pair always matches.
  • The disableLayerInteractions guard only covered the classic path — moved it (plus the no-feature check) into the emitter itself so all three click paths behave the same.
  • The vector-tile path never sent a pixel and deck.gl clicks with no coordinate reported lat/lng 0,0 — pixel now passes through the debounce, and missing coordinates emit null instead.
  • The payload handed out a live reference to the map's internal feature — it now emits a snapshot copy (properties cloned, deck.gl's lazy geometry getter preserved).
  • layerName could carry a plugin's private layer id on the engine path — it now resolves through asLayerUUID everywhere, so it's always the mission layer uuid or null.
  • The docs row promised more than the code did — rewritten to match actual behavior (2D engines only, programmatic selection also fires, nullable fields).
  • Zero tests on the event — extracted the payload builder into a pure module and added 7 specs covering the snapshot, copies, and null shapes.

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.

1 participant