Skip to content

Add GeoJSON geometry to hover, click and selection events - #7

Merged
db9795 merged 1 commit into
mainfrom
feat/event-geometry
Oct 12, 2026
Merged

db9795 merged 1 commit into
mainfrom
feat/event-geometry

Conversation

@db9795

@db9795 db9795 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Adds the location of every event as GeoJSON geometry, so the profile can be wired to a map (e.g. drawing the hovered point and the selected stretch of the route) without recomputing anything from distances.

Events

  • hover and click: lngLat is replaced by geometry, a GeoJSON Point.
  • selection and selectionend: new geometry with the selected stretch of the line. It has the type of the input geometry: LineString for a LineString, MultiLineString for a MultiLineString (one line per part the selection covers, never bridging the gap between two parts).
  • Coordinates are [lng, lat, ele], ele in meters like the input (also with units: "imperial"). Positions and elevations are interpolated on the line, including the ends of the selection, so custom calculations can use them directly.
  • The ele of the hover point is interpolated, while elevation stays the nearest sample, like the badge.
  • New exported types ElevationProfilePointGeometry and ElevationProfileLineGeometry.

Breaking

  • lngLat is removed from hover and click. Use e.geometry.coordinates.slice(0, 2) instead.
  • Released as minor anyway: the lib has not been public for long

Other

  • README (events) and tests updated.
  • Changeset: minor.

@db9795
db9795 merged commit 86b733e into main Oct 12, 2026
1 check passed
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