AW: [OpenLayers-Users] Convert to Long, Lat?

Arnd Wippermann arnd.wippermann at web.de
Mon Oct 31 08:03:57 EDT 2011


Hi,

Also the name seems to suggest, that getLonLatFromViewPortPx will return
Worldcoordinates in lon, lat, it really returns the coordinates in map
units.

You have to transform your coordinates: 

var P900913 = new OpenLayers.Projection("EPSG:900913");
var P4326   = new OpenLayers.Projection("EPSG:4326");

trigger: function(e) { 
    var xyCoords = map_Obj.getLonLatFromViewPortPx(e.xy); 

    var lonlat = xyCoords.transform(P900913, P4326);

    alert("You clicked near " + lonlat.lat + ", " + lonlat.lon);

    ...

Arnd 

-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Arnie Shore
Gesendet: Montag, 31. Oktober 2011 00:03
An: openlayers-users at lists.osgeo.org
Betreff: [OpenLayers-Users] Convert to Long, Lat?

I guess I missed something in the example at
http://openlayers.org/dev/examples/click.html

See my http://www.saefern.org/_osm/test6.php

Mebbe the noobie-est question so far, but how do I convert the displayed 
values to long, lat? (Line 48 there.)    Thanks, all.



_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users



More information about the Users mailing list