Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 =;

        infowin = new OpenLayers.Popup.FramedCloud(
                     new OpenLayers.Size(300,150),

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?

share|improve this question
Is there anything I can clarify to get some answers? – freddell Jun 28 '12 at 18:15

Maybe I'm not understanding the question, but does this example do what you want? Seems that the popup is anchored on the mouse position (unless the feature is near the edge of the map so the popup is shifted to fit on the map).

share|improve this answer

Have you tried to register "featureselected" and "featureunselected" events on your activeLayer and fire the infowindow event functions from there?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.