From 18098889c543b92b76c9d778afb25fd777fb138e Mon Sep 17 00:00:00 2001 From: Candid Dauth Date: Tue, 30 Dec 2014 16:14:13 +0100 Subject: [PATCH] Making sure that only one label is displayed at a time --- frontend/js/fpMap.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/frontend/js/fpMap.js b/frontend/js/fpMap.js index 8cc21d7a..261d451a 100644 --- a/frontend/js/fpMap.js +++ b/frontend/js/fpMap.js @@ -53,23 +53,25 @@ map.layerLines = new OpenLayers.Layer.Vector("Lines", { displayInLayerSwitcher: false, visibility: true }); map.map.addLayer(map.layerLines); + var label; map.featureHandler = new OpenLayers.Handler.Feature(null, map.layerLines, { "over" : function(obj) { $(map.map.div).addClass("fp-overFeature"); - if(!obj.fpLabel) { - if(obj.fpMarker && obj.fpMarker.name) - obj.fpLabel = map.showLabel(obj.fpMarker.name, obj.fpMarker, { x: 10, y: 0 }); - else if(obj.fpLine && obj.fpLine.name) - obj.fpLabel = map.showLabel(obj.fpLine.name, map.xyToPos(map.featureHandler.evt), { x: 15, y: 0 }, true); - } + if(label) + label.close(); + + if(obj.fpMarker && obj.fpMarker.name) + label = map.showLabel(obj.fpMarker.name, obj.fpMarker, { x: 10, y: 0 }); + else if(obj.fpLine && obj.fpLine.name) + label = map.showLabel(obj.fpLine.name, map.xyToPos(map.featureHandler.evt), { x: 15, y: 0 }, true); }, "out" : function(obj) { $(map.map.div).removeClass("fp-overFeature"); - if(obj.fpLabel) { - obj.fpLabel.close(); - obj.fpLabel = null; + if(label) { + label.close(); + label = null; } }, "click" : function(obj) {