Comments (7)
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 map.destroy()
function would need to handle these things and also clear any in-flight requests for tiles (otherwise the unload/error handlers for the images might cause errors when they return). That sounds scary but I'm pretty sure the request manager does the right thing already if you set a new provider, so it's probably just a matter of piggy-backing on that logic.
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.
from modestmaps-js.
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.
from modestmaps-js.
First shot at this work in https://github.com/stamen/modestmaps-js/tree/mapdestroy
This
- clears the request queue
- unbinds
window.resize
I'm uncertain as far as whether map.destroy
should kill all of the DOM elements the map creates, the map parent, or none of the above, so haven't pushed on that work yet.
from modestmaps-js.
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 destroy
:)
from modestmaps-js.
Yeah, I'll fold #45 into this ticket then to simplify the branching.
from modestmaps-js.
Cool, in b70e476 and 756950d , handlers are now removable and removed in mapdestroy
and layerParent
is removed from the page. I think this branch is ready to roll.
from modestmaps-js.
Fixed in 2fd8e7d
from modestmaps-js.
Related Issues (20)
- Coordinate -> Extent HOT 3
- anyscale example does not work?
- Remove cache infrastructure HOT 1
- node example broken? HOT 5
- Initialize map without layer HOT 1
- MM.Location bearing method HOT 3
- The example on http://modestmaps.com/ doesn't work now HOT 2
- Latest MM breaks at high zooms in IE8
- Geo code or search by location in modest map HOT 3
- displaying geojson "features" HOT 1
- map.setCenter ignores latitude HOT 7
- map rotation HOT 3
- Tiles disappear when max is hit on very large displays HOT 2
- Easey and setExtent HOT 5
- Center Zoom On Click - Wax and Modest Maps
- CallbackManager#dispatchCallback eats exceptions
- IE10 PointerEvents not working properly HOT 1
- PERSIAN GOULF MARITAM POSIT
- License for modestmaps HOT 2
- Which files need to be hosted?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modestmaps-js.