In a previous version of my program I used markers
to mark points on the map. In the current version I had to change from markers
to vectors
, because I need the extra flexibility. In the markers solution I used the function below to add a popup-box to a marker:
function createPopupBoxFeature(vector, lonLat, description) {
var feature = new OpenLayers.Feature(vector, lonLat);
feature.closeBox = true;
feature.popupClass = OpenLayers.Class(OpenLayers.Popup.AnchoredBubble,
{ "autoSize": true });
feature.data.popupContentHTML = description;
vector.events.register("mousedown", feature, function(evt) {
if (this.popup == null) {
this.popup = this.createPopup(this.closeBox);
map.addPopup(this.popup);
this.popup.show();
} else {
this.popup.toggle();
}
OpenLayers.Event.stop(evt);
});
return feature;
}
But it is no longer working for vectors
, because they have no events
property. How do I fix this?