add 'selectedFeature' member to Layer.Text so that when the user clicks a second time on the same marker, the popup disappears.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@456 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-05-29 18:25:56 +00:00
parent 8a21a1dba4
commit 82839000d6

View File

@@ -10,6 +10,9 @@ OpenLayers.Layer.Text.prototype =
* @type str */ * @type str */
location:null, location:null,
/** @type OpenLayers.Feature */
selectedFeature: null,
/** /**
* @constructor * @constructor
* *
@@ -102,11 +105,19 @@ OpenLayers.Layer.Text.prototype =
} }
} }
}, },
/**
* @param {Event} evt
*/
markerClick: function(evt) { markerClick: function(evt) {
sameMarkerClicked = (this == this.layer.selectedFeature);
this.layer.selectedFeature = (!sameMarkerClicked) ? this : null;
for(var i=0; i < this.layer.map.popups.length; i++) { for(var i=0; i < this.layer.map.popups.length; i++) {
this.layer.map.removePopup(this.layer.map.popups[i]); this.layer.map.removePopup(this.layer.map.popups[i]);
} }
this.layer.map.addPopup(this.createPopup()); if (!sameMarkerClicked) {
this.layer.map.addPopup(this.createPopup());
}
Event.stop(evt); Event.stop(evt);
} }
}); });