Resonators deletion of zoom level move

Change:
Move resonators deletion to 'zoomend' event of map.
Some clean up of code.
This commit is contained in:
Xelio
2013-02-10 22:23:01 +08:00
parent f781c6ebd4
commit 6936ef1d05
2 changed files with 35 additions and 24 deletions

View File

@ -93,7 +93,22 @@ window.setupMap = function() {
map.attributionControl.setPrefix('');
// listen for changes and store them in cookies
map.on('moveend', window.storeMapPosition);
map.on('zoomend', window.storeMapPosition);
map.on('zoomend', function() {
window.storeMapPosition;
// remove all resonators if zoom out to < RESONATOR_DISPLAY_ZOOM_LEVEL
if (isResonatorsShow()) return;
for(var i = 1; i < portalsLayers.length; i++) {
portalsLayers[i].eachLayer(function(item) {
var itemGuid = item.options.guid;
// check if 'item' is a resonator
if(!window.resonators[itemGuid]) return;
portalsLayers[i].removeLayer(item);
});
}
console.log('Remove all resonators');
});
$("[name='leaflet-base-layers']").change(function () {
writeCookie('ingress.intelmap.type', $(this).parent().index());
});