From 82839000d64f4c9c7c8b2f802fab026e58aa17d5 Mon Sep 17 00:00:00 2001 From: euzuro Date: Mon, 29 May 2006 18:25:56 +0000 Subject: [PATCH] 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 --- lib/OpenLayers/Layer/Text.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Layer/Text.js b/lib/OpenLayers/Layer/Text.js index e655275a72..2124bcab01 100644 --- a/lib/OpenLayers/Layer/Text.js +++ b/lib/OpenLayers/Layer/Text.js @@ -10,6 +10,9 @@ OpenLayers.Layer.Text.prototype = * @type str */ location:null, + /** @type OpenLayers.Feature */ + selectedFeature: null, + /** * @constructor * @@ -102,11 +105,19 @@ OpenLayers.Layer.Text.prototype = } } }, + + /** + * @param {Event} 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++) { 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); } });