kopia lustrzana https://github.com/FacilMap/facilmap
Making sure that only one label is displayed at a time
rodzic
8d13890e22
commit
18098889c5
|
@ -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) {
|
||||||
|
|
Ładowanie…
Reference in New Issue