clear portal names immediately on a zoom end

This commit is contained in:
Jon Atkins 2014-06-08 07:39:59 +01:00
parent c23f902f48
commit 751001c6fa

View File

@ -2,7 +2,7 @@
// @id iitc-plugin-portal-names@zaso // @id iitc-plugin-portal-names@zaso
// @name IITC plugin: Portal Names // @name IITC plugin: Portal Names
// @category Layer // @category Layer
// @version 0.1.4.@@DATETIMEVERSION@@ // @version 0.1.5.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@ // @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@ // @downloadURL @@DOWNLOADURL@@
@ -72,6 +72,13 @@ window.plugin.portalNames.addLabel = function(guid, latLng) {
} }
} }
window.plugin.portalNames.clearAllPortalLabels = function() {
for (var guid in window.plugin.portalNames.labelLayers) {
window.plugin.portalNames.removeLabel(guid);
}
}
window.plugin.portalNames.updatePortalLabels = function() { window.plugin.portalNames.updatePortalLabels = function() {
// as this is called every time layers are toggled, there's no point in doing it when the leyer is off // as this is called every time layers are toggled, there's no point in doing it when the leyer is off
if (!map.hasLayer(window.plugin.portalNames.labelLayerGroup)) { if (!map.hasLayer(window.plugin.portalNames.labelLayerGroup)) {
@ -171,6 +178,8 @@ var setup = function() {
window.addHook('requestFinished', function() { setTimeout(function(){window.plugin.portalNames.delayedUpdatePortalLabels(3.0);},1); }); window.addHook('requestFinished', function() { setTimeout(function(){window.plugin.portalNames.delayedUpdatePortalLabels(3.0);},1); });
window.addHook('mapDataRefreshEnd', function() { window.plugin.portalNames.delayedUpdatePortalLabels(0.5); }); window.addHook('mapDataRefreshEnd', function() { window.plugin.portalNames.delayedUpdatePortalLabels(0.5); });
window.map.on('overlayadd overlayremove', function() { setTimeout(function(){window.plugin.portalNames.delayedUpdatePortalLabels(1.0);},1); }); window.map.on('overlayadd overlayremove', function() { setTimeout(function(){window.plugin.portalNames.delayedUpdatePortalLabels(1.0);},1); });
window.map.on('zoomend', window.plugin.portalNames.clearAllPortalLabels );
} }
// PLUGIN END ////////////////////////////////////////////////////////// // PLUGIN END //////////////////////////////////////////////////////////