[OpenLayers-Users] [OpenLayers-Dev] Get lat/lon from user click?

Robert Hicks robhyx at gmail.com
Mon Dec 21 17:31:08 EST 2009


Great, thanks everyone! I got what I needed and it works great!

On Mon, Dec 21, 2009 at 3:43 PM, Rodolfo Barriga
<rodolfo.barriga at gmail.com>wrote:

> you can create a custom openlayer control ... something like this
>
>
>
> OpenLayers.Control.
> ClickLayerInfo = OpenLayers.Class(OpenLayers.Control, {
>     defaultHandlerOptions: {
>         'single': true,
>         'double': false,
>         'pixelTolerance': 0, //tolarance
>         'stopSingle': false,
>         'stopDouble': false
>     },
>     initialize: function(options) {
>         this.handlerOptions = OpenLayers.Util.extend(
>             {}, this.defaultHandlerOptions
>         );
>         OpenLayers.Control.prototype.initialize.apply(
>             this, arguments
>         );
>         this.handler = new OpenLayers.Handler.Click(
>             this, {
>                 'click': this.trigger
>             }, this.handlerOptions
>         );
>     },
>     trigger: function(e) {
>         var lonLat = you_map.getLonLatFromViewPortPx(e.xy);
>
>         // you cant transform you lat and lon
>         // you can def a pixel buffer with the map resolution
>         // you can do a asyn call
>     }
> });
>
> its work for me !! :-)
> gretting Rodolfo B.
>
>
> 2009/12/21 Robert Hicks <robhyx at gmail.com>
>
>> Hey all, is there a way to get the coordinates of a point on the map that
>> a user has just clicked on? I see Mouse-position displays the coordinates at
>> the bottom of the screen, and I also see you can register muliple mouse
>> events to te map, but I need to store coordinates in a javascript var to
>> send in a request to my server.
>>
>> Thanks!
>>
>> --
>> web http://www.hyxspace.com
>> aim hyx1138
>>
>> _______________________________________________
>> Dev mailing list
>> Dev at openlayers.org
>> http://openlayers.org/mailman/listinfo/dev
>>
>>
>


-- 
web http://www.hyxspace.com
aim hyx1138
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091221/eb0166d7/attachment.html


More information about the Users mailing list