bugfix: update portal level layer if it already exists instead of ignoring the addLabel call

This commit is contained in:
Philipp Schaefer 2014-03-25 00:24:12 +01:00
parent 5a033a971a
commit 64bd129c02

View File

@ -52,9 +52,12 @@ window.plugin.portalLevelNumbers.removeLabel = function(guid) {
} }
window.plugin.portalLevelNumbers.addLabel = function(guid,latLng) { window.plugin.portalLevelNumbers.addLabel = function(guid,latLng) {
var previousLayer = window.plugin.portalLevelNumbers.levelLayers[guid];
if (!previousLayer) {
// remove old layer before updating
var previousLayer = window.plugin.portalLevelNumbers.levelLayers[guid];
if (previousLayer) window.plugin.portalLevelNumbers.removeLabel(guid);
// add portal level to layers
var p = window.portals[guid]; var p = window.portals[guid];
var levelNumber = p.options.level; var levelNumber = p.options.level;
var level = L.marker(latLng, { var level = L.marker(latLng, {
@ -68,7 +71,6 @@ window.plugin.portalLevelNumbers.addLabel = function(guid,latLng) {
plugin.portalLevelNumbers.levelLayers[guid] = level; plugin.portalLevelNumbers.levelLayers[guid] = level;
level.addTo(plugin.portalLevelNumbers.levelLayerGroup); level.addTo(plugin.portalLevelNumbers.levelLayerGroup);
} }
}
window.plugin.portalLevelNumbers.updatePortalLabels = function() { window.plugin.portalLevelNumbers.updatePortalLabels = function() {