Leaflet.glify
Leaflet.glify copied to clipboard
How can I pass a className to individual points?
Hi, I know I can pass a custom className for the whole canvas. But I was wondering if there is any way to pass a custom className to the individual rendered points right now?
To put this in context, I am basically trying to hide individual points on click trigger. If passing the custom className to individual points after the render is not supported atm, do you have any thoughts/suggestions on how I can do that with the functionality that is already there?
Thank you guys, you are doing a great job ❤️
I'm pretty much sure you can not at all, since points rendered on canvas are not HTML elements.
If you want to dynamically hide/show certain points, you should change the data source during the runtime and trigger re-render (there may be better ways to do so, though that's the only one I know, and most certainly it should work).
@neilm-code Doable by storing the index of the point in the properties
of its GeoJSON. Then write your click handler to get the index from the feature and pass it to .remove()
. Here's an example of how I've used this method to fetch data about the point on click: see renderGeography()