javascript - Deconstructing an Open Layers 3 map -


so, using open layers 3 ember.js make dashboard, , i've made map load dynamically want destroyed when leave route, thing found map.destroy() old version of api , there don't seem 1 in new version.

i used chrome debugger after going map page couple of times , found had 29 ol.map objects.

this have far

app.mapview = ember.view.extend({   map: null,   didinsertelement: function() {     this.map = new ol.map({       target: 'map',       layers: [         new ol.layer.tile({           source: new ol.source.mapquest({layer: 'sat'})         })       ],       view: new ol.view({         center: ol.proj.transform([37.41, 8.82], 'epsg:4326', 'epsg:3857'),         zoom: 4       })     });   },   willdestroyelement: function() {     // destroy this.map   } }); 

i cant find in docs removing maps.

thanks in advance.

you should try this:

app.mapview = ember.view.extend({   // if not using ember.get/set you'd better make "private"   _map: null,   didinsertelement: function() {     this._map = new ol.map(...);   },   willdestroyelement: function() {     this._map.settarget(null);     this._map = null;   } }); 

it detach map element , allows correct garbage collection. don't forget remove other references map object if any.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -