-
Notifications
You must be signed in to change notification settings - Fork 152
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
Removing maps? #55
Comments
This is something that isn't supported properly yet, but definitely should be. If your Map is initialized without dimensions then it will listen for resize events on the window. This needs cleaning up if the Map is removed. The MouseHandler object also listens for events on window but doesn't (yet) have a way remove them. A Hopefully we can look at this soon if it's not something you want to tackle yourself. In the meantime, honestly, 10 maps should be fine because there's not a lot of overhead to a map once the images have loaded. But if they really aren't all visible at once (e.g. in a slide show) and you want to conserve memory/resources, consider a creating a pool of maps that you recycle by resetting the provider (if needed) and moving the parent element around in the DOM. The only caveat I can think of is that you might need to keep the maps in the DOM somewhere for some of the loading events to work, but you should be able to put a map in an element hidden with display:none without trouble. |
Thanks @RandomEtc. Yes, the layout is similar to a slideshow. I'm not seeing any real performance issues at this point but wanted to play it safe. Thanks for this information. |
First shot at this work in https://github.com/stamen/modestmaps-js/tree/mapdestroy This
I'm uncertain as far as whether |
Looks good so far. Removing the mouse/touch event handlers would be the next main thing, and I'd say just go for it and clear all the DOM elements too. If that's not what you want, don't call |
Yeah, I'll fold #45 into this ticket then to simplify the branching. |
Fixed in 2fd8e7d |
What's the best way to remove a map? Is it just to remove the maps container? I'm working on a page that will have about 10 maps, but doesn't need to have more than 3 at a time.
The text was updated successfully, but these errors were encountered: