Reputation: 2481
I am using openLayers and creating a OSM base layer. By default the layer use EPSG:900913 and the coordinates are in meters. I want to use coordinates in degrees with EPSG:4326 so I initilize layer with:
base_layer.addOptions({ sphericalMercator: true,
projection: new OpenLayers.Projection('EPSG:4326')}, true);
Now the map uses degrees but have the next problem: The point with latitude 37.296 and longitude -5.929 (http://www.openstreetmap.org/?lat=37.296&lon=-5.929&zoom=12&layers=Q# and the same coordinates in Google Maps) appears to me (moving map and executing map.getCenter()
in firebug) in lat. -49.75, lon. -5.929.
Why? How can I use an OSM layer with same degrees coordinates as in openstreetmap.org
and as are returned by nominatim.openstreetmap.org
?
Upvotes: 1
Views: 2418
Reputation: 9230
You can't just claim the layer is EPSG:4326
when the tiles you are displaying are actually rendered in EPSG:3857
. That is nonsensical.
I'm not quite clear on what you are trying to do here to be honest, but it may help to set displayProjection
to EPSG:4326
which will cause OpenLayers to use degrees when it is communicating values to/from the user.
If you want to to read or set the map location in code then you will need to reproject the value you get from getCenter
or give to setCenter
yourself by calling the transform
method on the location value.
Upvotes: 2