Leaflet.glify icon indicating copy to clipboard operation
Leaflet.glify copied to clipboard

Add polygons to existing layer

Open Jadaw1n opened this issue 6 years ago • 3 comments

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).

Jadaw1n avatar Feb 12 '19 19:02 Jadaw1n

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.

spencermize avatar Mar 13 '19 16:03 spencermize

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.

robertleeplummerjr avatar Mar 13 '19 17:03 robertleeplummerjr

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.

image

vs image

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!

spencermize avatar Mar 14 '19 18:03 spencermize