Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
    
Is there anything I can clarify to get some answers? –  freddell Jun 28 '12 at 18:15
1  
You can improve your acceptance rate. –  CaptDragon Oct 12 '12 at 16:02
add comment

2 Answers

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).

http://openlayers.org/dev/examples/getfeatureinfo-popup.html

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

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.