I have a vector layer overlaid above a base layer. Basically I want to have a popup anchored at the clicked position when clicking anywhere on the vector geometries. So I have the code:
var selectCtrl = new OpenLayers.Control.SelectFeature(activeLayer, {
clickout: true,
onSelect: open_infowin,
onUnselect: close_infowin
});
function open_infowin(event) {
var mousePos = this.events.getMousePosition(event);
infowin = new OpenLayers.Popup.FramedCloud(
"popup",
map.getLonLatFromViewPortPx(mousePos),
new OpenLayers.Size(300,150),
"Updating<br/>information...",
null,
true,
null
);
map.addPopup(infowin);
}
But the OnSelect function passes an event object with no mouse position. If I register mouse events with the Map, no event will be fired when the mouse moves on the vector layer.
Any suggestion?