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:
@@ -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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user