Skip to content
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

Creating and removing shapes doesnt remove the WebGL Context #161

Closed
jackbarrie1341 opened this issue Oct 25, 2024 · 2 comments
Closed

Creating and removing shapes doesnt remove the WebGL Context #161

jackbarrie1341 opened this issue Oct 25, 2024 · 2 comments

Comments

@jackbarrie1341
Copy link

I have thousands of polygons i am rendering, and i need to be able to show/hide them and also update the opacity of them. Currently i am creating them any time an update needs to happen like this:
let glifyPolygons = glify.shapes({ map: map, data: colouredGrids, click: (e: any, feature: GeoJSON.Feature) => { handleGridClick(feature); }, color: (index: any, shape: any) => hexToRgb(shape.properties.color, transparency[0] / 100), });
Then any time a i need to hide or change the opacity, i remove it:
glifyPolygons.remove()
then redraw the polygons with the new opacity. However when i show/hide the polygons alot or update the opacity too frequently I get a warning in the console:

WARNING: Too many active WebGL contexts. Oldest context will be lost.

Then other shapes i am drawing with glify start to be deleted. It seems like the WebGL contexts arent being removed. I found a quick solution to show/hide by doing this:
if (layer && !state) { layer.remove(); } else if (layer && state) { layer.addTo(map); }
but the polygon data can also change so i need to be able to create new shape objects.
How can i fix this?

@trafficonese
Copy link
Contributor

duplicate of #24 ?
related to #67

@charlieforward9
Copy link
Collaborator

@jackbarrie1341 as indicated above, this is a duplicate, so I will close it to keep the issue list clean.

Check out this hook I made to streamline the updating of your glify layers.

@charlieforward9 charlieforward9 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants