protomaps / protomaps-leaflet

Lightweight vector map rendering + labeling and symbology for Leaflet
https://protomaps.com/docs/frontends/leaflet
BSD 3-Clause "New" or "Revised" License
757 stars 43 forks source link

add X-ray inspector mode for leaflet frontend #47

Closed bdon closed 3 years ago

bdon commented 3 years ago

Because the Leaflet frontend already assumes the leaflet dependency, we can reuse some DOM elements to display the feature ID, type and properties.

bdon commented 3 years ago

very basic implementation in v1.3.0, screenshot:

Screen Shot 2021-09-08 at 3 51 03 PM

issues right now: it does hit detection based on bounding box, which will include way too many features: we need a very primitive distance-to-linestring, as well as point-in-polygon implementation to do this more accurately. open to feedback

bdon commented 3 years ago

scrolling around aggressively and clicking on zoom transition seems to break the inspector. also consider:

maybe using console.log is a better option? maybe a hovering window instead of reusing leaflet popups?