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

Open
jackbarrie1341 opened this issue Oct 25, 2024 · 1 comment
Open

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

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

2 participants