CodePen example: https://codepen.io/dandormont-the-decoder/pen/OJmQZZy
I have a vector tile layer which I am displaying instead of a Feature layer because it renders _much_ more efficiently with Leaflet. I do also have access to the underlying Feature data in a separate hosted layer. I added a `bindPopup` call to the layer for illustration but as you can see it doesn't do anything.
What I'd like to do is on click or some other gesture, be able to retrieve and display some data about the underlying feature. I admit I'm not super familiar with how vector tile layers really work but my understanding is that the vector data is somehow tagged with metadata about the underlying features, I'm just trying to figure out how to tap into that.
If it can't be done directly in esri-leaflet-vector, is there a way to tie into the underlying mapbox-gl/maplibre-gl object and access it that way?
Thanks,
Dan
Hello Dan,
Thank you for your inquiry. I have a few comments that will hopefully address this issue.
I hope this helps and please let us know if you have any other questions.
Hi @c_yatteau ,
Thanks for that example, it's very helpful. And I see what you mean about the distance issue. It's a bit awkward but I think it may be the best option. And now that I think of it, in some of my live applications the user isn't actually clicking on an individual feature but rather "geofencing" by drawing a boundary around a set of features, and the geometry query against the feature service should be able to handle that nicely.
But I'm curious about your point 3 above. I'm having a lot of trouble getting complex feature layers to perform well with Leaflet. Here's another example of one that my colleague found which is a list of UFO Sightings: https://codepen.io/dandormont-the-decoder/pen/qByJpNM the page basically freezes. But the same data in a vector tile layer loads nicely, https://codepen.io/dandormont-the-decoder/pen/qByJpzz
(I'm not sure why one of them has big marker pins and the other little colored dots, I'm still learning my way around the style editor and such) This is a point layer with around 20,000 features, which doesn't seem like a massive number. Any suggestions?
Thanks,
Dan
Hello @DanielDormontl,
After looking into this issue further, it appears that Esri Leaflet will generally be good up to ~10k points/vertices on screen at any one time. My colleague suggested possibly switching to something like https://github.com/Esri/Leaflet.shapeMarkers which may be more performant to draw.
From an implementation perspective, when dealing with larger datasets, our ArcGIS Maps SDK for JS is the more efficient way to go when requesting and drawing features. This is due to the fact that Leaflet uses <svg> elements as opposed to WebGL like the Maps SDK for JS does when drawing features. Another advantage is the Maps SDK for JS request features in protocol buffer format which is more compact. For reference, I created this CodePen using the Maps SDK for JS and the UFO feature layer you provided.
In general, future performance improvements in these aspects for Esri Leaflet may occur but are not guaranteed. Please let me know if you have further questions or comments.