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 */
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]);
}
if (!sameMarkerClicked) {
this.layer.map.addPopup(this.createPopup());
}
Event.stop(evt);
}
});