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'm have been searching for several hours and do not find a way to get mouse coordinates after a SelectFeature, which returns the feature by itself. I saw that this has been asked several times earlier, so I try again !

Thanks very much,

Olivier

share|improve this question
    
I need an answer to this aswell. –  netbrain Mar 27 '12 at 9:12
add comment

1 Answer

You can get it with these ways:

feature.geometry.getBounds().getCenterLonLat()

or

map.events.register("click", map, function(e) { 
    var latlon = map.getLonLatFromViewPortPx(e.xy) ;
    alert(lonlat)
});

or

new OpenLayers.Control.SelectFeature(layer,{
    hover:true,
    eventListeners:{
      onSelect:function(e){
        alert(e.feature.geometry)
    }
});

or

layer.events.on({
            "featureselected": function(e) {       
            alert(e)
            }
});    

i hope it helps you....

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.