[OpenLayers-Users] Can't transform lat/long to a projection

winfield.dave winfield.dave at gmail.com
Mon Jul 13 08:27:21 EDT 2009


Hi all,

Essentially, I'm having a problem converting some lat/long values I get back
from a webservice onto my map. The map is using EPSG:3395, so I thought code
like this would work.

<!-- at the top -->
var latLonProj = new OpenLayers.Projection("EPSG:4236");
var osmProj = new OpenLayers.Projection("EPSG:3395");

<!-- code that matters -->
var markers = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markers);

var ll = new OpenLayers.LonLat(51.644715, -0.0327);
ll.transform(latLonProj, osmProj);

<!-- code for the icon and adding to the map -->
var size = new OpenLayers.Size(10,17);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var icon = new
OpenLayers.Icon('http://boston.openguides.org/markers/AQUA.png',size,offset);
markers.addMarker(new OpenLayers.Marker(ll,icon));

I can do an alert on the ll.lon and ll.lat values AFTER the transform and
they're the same as what I passed into the constructor.

I thought maybe I had the lon/lat values reversed, so I changed the order of
the parameters in the LonLat constructor, but it did not help.  I was also
under the impression that EPSG:4236 was the geographic coordinates, but I
could be wrong.

Any thoughts?
-- 
View this message in context: http://n2.nabble.com/Can%27t-transform-lat-long-to-a-projection-tp3250372p3250372.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list