-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use Leaflet's L.circleMarker to deal with performance issues #10
Comments
Hey @answerquest glad you have you here |
I think I found where the markers code is: https://github.com/aswinmohanme/kerala-flood-map/blob/master/src/components/mainPage/mainPageMap.js#L30 |
Yeah, the custom marker images are one of the major performance issues |
Yikes, my bad, the L.divIcon isn't the way to improve page performance; it's by using L.circleMarker and a custom SVG renderer. Its explained on this stackoverflow post. The jsfiddle linked has 100k points rendered with no drag on page. This would require changes other than just replacing the icon declarations as I'd assumed earlier. |
This is how the code for L.circleMarker would look in Vanilla JS.
Trying to see how it can be done in react. Docs. |
Also, better to add the different colors markers to different layers entirely, then the user can switch them on/off. If anyone knows react-leaflet, I'd love some translation help! I can do it all in simple leaflet js. |
For performance issues, Suggestion: use Leaflet's L.divIcon. Enables much higher number of points on map (several thousands or more). Can assign it classes based on metadata and use CSS to give it any shape/color (I recommend small colored dots instead of large markers). Sharing a snippet.
Will try to make a PR, but might just share the proposed snippet here if there's other things to change (like css) and I can't figure things out. Apologies but I haven't worked on react js yet.
The text was updated successfully, but these errors were encountered: