Making sure that only one label is displayed at a time

before-bootstrap
Candid Dauth 2014-12-30 16:14:13 +01:00
rodzic 8d13890e22
commit 18098889c5
1 zmienionych plików z 11 dodań i 9 usunięć

Wyświetl plik

@ -53,23 +53,25 @@
map.layerLines = new OpenLayers.Layer.Vector("Lines", { displayInLayerSwitcher: false, visibility: true }); map.layerLines = new OpenLayers.Layer.Vector("Lines", { displayInLayerSwitcher: false, visibility: true });
map.map.addLayer(map.layerLines); map.map.addLayer(map.layerLines);
var label;
map.featureHandler = new OpenLayers.Handler.Feature(null, map.layerLines, { map.featureHandler = new OpenLayers.Handler.Feature(null, map.layerLines, {
"over" : function(obj) { "over" : function(obj) {
$(map.map.div).addClass("fp-overFeature"); $(map.map.div).addClass("fp-overFeature");
if(!obj.fpLabel) { if(label)
if(obj.fpMarker && obj.fpMarker.name) label.close();
obj.fpLabel = map.showLabel(obj.fpMarker.name, obj.fpMarker, { x: 10, y: 0 });
else if(obj.fpLine && obj.fpLine.name) if(obj.fpMarker && obj.fpMarker.name)
obj.fpLabel = map.showLabel(obj.fpLine.name, map.xyToPos(map.featureHandler.evt), { x: 15, y: 0 }, true); 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) { "out" : function(obj) {
$(map.map.div).removeClass("fp-overFeature"); $(map.map.div).removeClass("fp-overFeature");
if(obj.fpLabel) { if(label) {
obj.fpLabel.close(); label.close();
obj.fpLabel = null; label = null;
} }
}, },
"click" : function(obj) { "click" : function(obj) {