[OpenLayers-Users] openlayer markers located at the wrong place
Mario Danelli
mario.danelli at gmail.com
Fri May 31 00:11:55 PDT 2013
Dear Maven,
> Once you move the map, the marker will be located at the wrong place, why?
As I see from your example, the marker is located in a wrong position at
start-up. It's placed near LAT 0 and LON 0.
You should use the TRANSFORM method to change from projection WGS 1984
(tipically used) to projection Mercator (used in OpenStreetMap tiles). See
the following code for a brief presentation:
------------------> BEGIN
// transform from WGS 1984
var fromProjection = new OpenLayers.Projection("EPSG:4326");
// to Spherical Mercator Projection
var toProjection = new OpenLayers.Projection("EPSG:900913");
new OpenLayers.LonLat(YOUR_MARKER_LON, YOUR_MARKER_LAT)
.transform(fromProjection, toProjection);
<------------------ END
Regards
Mario Danelli
More information about the Users
mailing list