<div dir="ltr"><div>Oh, there is a mistake in the example.  I fixed it yet. <a href="http://jsfiddle.net/3pPB3/2/">http://jsfiddle.net/3pPB3/2/</a><br><br></div><div>In fact, what I said about the marker located at a wrong place is not related to the initializate location of the marker.<br>

<br></div><div>You may notice this function in my script:<br><br><br><i>        map.events.register("click", map, function(evt) {<br>            var pos = map.getLonLatFromPixel(evt.xy);<br>            updateMaker(myMarker, pos);<br>

        });<br><br>        function updateMaker(myMarker, pos) {<br>            myMarker.moveTo(myMarker.map.getPixelFromLonLat(pos));<br>        }</i><br><br></div><div>As you can see, once I click on the map, I want the marker's position updated and re-located.<br>

<br></div><div>Everything goes well if you do not move the map, but once you drag the map , the then click the map, you will find that the marker is located at a wrong place rather than the position where the mouse resides. <br>

<br></div><div>.<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/5/31 Mario Danelli <span dir="ltr"><<a href="mailto:mario.danelli@gmail.com" target="_blank">mario.danelli@gmail.com</a>></span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear Maven,<br>
<div class="im"><br>
> Once you move the map, the marker will be located at the wrong place, why?<br>
<br>
</div>As I see from your example, the marker is located in a wrong position at<br>
start-up. It's placed near LAT 0 and LON 0.<br>
<br>
You should use the TRANSFORM method to change from projection WGS 1984<br>
(tipically used) to projection Mercator (used in OpenStreetMap tiles). See<br>
the following code for a brief presentation:<br>
<br>
<br>
------------------> BEGIN<br>
<br>
// transform from WGS 1984<br>
var fromProjection = new OpenLayers.Projection("EPSG:4326");<br>
<br>
// to Spherical Mercator Projection<br>
var toProjection = new OpenLayers.Projection("EPSG:900913");<br>
<br>
new OpenLayers.LonLat(YOUR_MARKER_LON, YOUR_MARKER_LAT)<br>
.transform(fromProjection, toProjection);<br>
<br>
<------------------ END<br>
<br>
Regards<br>
<br>
Mario Danelli<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
</blockquote></div><br></div>