[OSM-dev] Calculate Latitude coordinate in map

Nick Whitelegg nick at hogweed.org
Mon Jan 7 10:08:34 GMT 2008


On Sunday 06 Jan 2008 15:39, al_ku at web.de wrote:
> Hello guys,
>
>
>
> I just started to work a little with your map and wanted to write a small
> test application to see it in action (I wanted to used it later for easier
> map editing on OSM).
>

In OpenLayers you can convert pixel coordinates to geographical coordinates 
using

var p = map.getLonLatFromViewPortPx (px);

The projection is a spherical Mercator projection - so you'll then need to 
convert that to lat/lon. In

http://www.free-map.org.uk/freemap/javascript/lib/converter.js

is code to convert to lat/lon: look in the "Google" section of the switch 
statement - this is taken from the main OSM site.

Nick




More information about the dev mailing list