Leaflet.glify
Leaflet.glify copied to clipboard
Add polygons to existing layer
Hi
Is there a way to add polygons to an existing layer? I have data that is loaded after a user moves around on the map. If I create a new layer each time, then the old layers will vanish at some point (Chrome says: "WARNING: Too many active WebGL contexts. Oldest context will be lost." in the console).
The only way I've found to manage this so far is to keep an external state and update the entire drawing:
webGL.settings.data = geoJSON;
webGL.setup().render();
I'd love it if I could just redraw the parts that have changed but I haven't dove that far in yet.
If we can think of a super clean way to first pick the shape, update it or delete it, then redraw, in a straightforward manner, then I can implement it.
I'm mostly curious about this issue re: performance. Currently, using Points to map out the same number of 'places' renders much faster than Shapes.
vs
It seems like the bulk of my performance bottleneck comes from the render->Shapes.resetVertices function, which has a lot going on that I don't quite understand (because of my lack of skill, not because of the quality of code!). That said, I think we'd have to drastically change the Shapes.resetVertices function in order to realize any speed improvements on an update (vs. my current method of just replacing the entire dataset and re-rendering), because it iterates over every item in GeoJSON.Features.
I don't see a great way to just update part of the canvas, but I'm also really pushing up against the boundaries of my current knowledge base!