diff --git a/code/map_data.js b/code/map_data.js index 4bf24c50..6c47155e 100644 --- a/code/map_data.js +++ b/code/map_data.js @@ -147,25 +147,25 @@ window.cleanUp = function() { // portal must be in bounds and have a high enough level. Also don’t // remove if it is selected. var itemGuid = item.options.guid; - switch(getTypeByGuid(itemGuid)){ + switch(getTypeByGuid(itemGuid)) { case TYPE_PORTAL: if(itemGuid == window.selectedPortal || - (b.contains(item.getLatLng()) && i >= minlvl)) return; + (b.contains(item.getLatLng()) && i >= minlvl)) return; cnt[0]++; //remove attached resonators - for(var j = 0; j <= 7; j++) removeByGuid( portalResonatorGuid(itemGuid,j) ); + for(var j = 0; j <= 7; j++) removeByGuid(portalResonatorGuid(itemGuid,j)); portalsLayers[i].removeLayer(item); break; case TYPE_RESONATOR: - // remove all resonator if zoom level become + // remove all resonators if zoom level become // lower than RESONATOR_DISPLAY_ZOOM_LEVEL if (map.getZoom() < RESONATOR_DISPLAY_ZOOM_LEVEL) - portalsLayers[i].removeLayer(item); + for(var j = 0; j <= 7; j++) portalsLayers[j].removeLayer(item); break; } }); @@ -203,7 +203,9 @@ window.removeByGuid = function(guid) { break; case TYPE_RESONATOR: if(!window.resonators[guid]) return; - portalsLayers[window.resonators[guid].options.pLevel].removeLayer(window.resonators[guid]); + var r = window.resonators[guid] + for(var i = 1; i < portalsLayers.length; i++) + portalsLayers[i].removeLayer(r); break; default: console.warn('unknown GUID type: ' + guid); @@ -267,41 +269,35 @@ window.renderPortal = function(ent) { window.map.setView(latlng, 17); }); - window.renderResonator(ent); + window.renderResonators(ent); // portalLevel contains a float, need to round down p.addTo(portalsLayers[parseInt(portalLevel)]); } -window.renderResonator = function(ent) { +window.renderResonators = function(ent) { var portalLevel = getPortalLevel(ent[2]); if(portalLevel < getMinPortalLevel() && ent[0] != selectedPortal) return; if(map.getZoom() < RESONATOR_DISPLAY_ZOOM_LEVEL) return; - for(var i=0; i