[OpenLayers-Users] How to capture lonlat from GetFeature control/WFS protocol?

Eric Lemoine eric.lemoine at camptocamp.com
Sun Mar 14 01:58:01 EST 2010


On Wednesday, March 10, 2010, Zer  wrote:
>
> Hi,
>
> I am using the GetFeature control together with WFS protocol to get a
> feature from the server when a user clicks a WMS layer. I need to capture
> the lon/lat of the point where the user clicked, together with the feature
> attributes returned from the server. Is there a way to get the point where
> the user clicked? Or do I have to extend the control?

Hi.

"featureselected" listeners aren't provided with that information.

But you may want to try the following in you "featureselected" listener:

    var lonlat = map.getLonLatFromPixel(control.click.down);

Untested!

Even if it works there are two problems with doing that :

- control.click.down doesn't give the click position, it gives the
mousedown position. So if the mouse moves between mousedown and
mouseup then control.click.down is not the click position. By default
Handler.Click has "pixelTolerance" set to 2.

- doing this involves accessing private variables, so it may break
with futures OpenLayers versions.

Cheers,


>
> Thanks,
>
> -ZM
> --
> View this message in context: http://n2.nabble.com/How-to-capture-lonlat-from-GetFeature-control-WFS-protocol-tp4711560p4711560.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com



More information about the Users mailing list