<div dir="ltr"><div><div><div><div><div><div><span name="Mario Danelli">Mario Danelli:<br><br></span></div><span name="Mario Danelli">Thanks for your attention and the codes.<br><br>It seem that the `OpenLayers.Marker` have no native support methods like `setPosition()` or something else to update its position.<br>


<br></span></div><span name="Mario Danelli">Since in my opinion, destroy-create-destroy.. will be a performance </span><span>consuming problem, that is why I keep one object of  `Marker` to reuse it.<br><br></span></div>

<span>I think it is a pity. <br><br></span></div><span>APIs like this kinds should be considered. <br><br></span></div><span>And I hope the development team of OL will notice this post. :)<br><br></span></div><span>And thank you anyway. :)<br>

</span><div><div><div><div><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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">


Dear Maven,<br>
<div><br>
> As you can see, once I click on the map, I want the marker's position<br>
updated and re-located.<br>
<br>
</div>As you can see, from the following link too<br>
<br>
<a href="http://stackoverflow.com/questions/9278174/how-to-move-a-marker-in-an-openlayers-layer-markers-layer" target="_blank">http://stackoverflow.com/questions/9278174/how-to-move-a-marker-in-an-openlayers-layer-markers-layer</a><br>



<br>
It seems that the "moveTo" -- is not "official" APIMethod -- or in any case<br>
there are some problems with it.<br>
<br>
So I tried removing and adding a new marker at any click on map.<br>
Below the JS code, that runs as expected, I tried in your example.<br>
As you can see I changed the code of "updateMaker" function.<br>
<br>
---------> BEGIN<br>
<br>
$(window).load(function() {<br>
        var map = new OpenLayers.Map("map");<br>
        map.addControl(new OpenLayers.Control.MousePosition());<br>
        var osm = new OpenLayers.Layer.OSM();<br>
        map.addLayer(osm);<br>
        // Set view to zoom maximum map extent<br>
        map.zoomToMaxExtent();<br>
<br>
                var markers = new OpenLayers.Layer.Markers("Markers");<br>
                map.addLayer(markers);<br>
<br>
        myMarker = new OpenLayers.Marker(new OpenLayers.LonLat(0,0));<br>
                markers.addMarker(myMarker);<br>
<div><br>
                map.events.register("click", map, function(evt) {<br>
                        var pos = map.getLonLatFromPixel(evt.xy);<br>
                        updateMaker(myMarker, pos);<br>
                });<br>
<br>
</div>                function updateMaker(myMarkerIn, pos) {<br>
                          //myMarker.moveTo(myMarker.map.getPixelFromLonLat(pos));<br>
                   markers.removeMarker(myMarkerIn);<br>
           myMarkerIn.destroy();<br>
           myMarker = new OpenLayers.Marker(pos);<br>
                   markers.addMarker(myMarker);<br>
                }<br>
        });<br>
<br>
<--------- END<br>
<br>
I hope it can be useful.<br>
<div><div><br>
Regards<br>
<br>
Mario Danelli<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.osgeo.org" target="_blank">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>
</div></div></blockquote></div><br></div></div></div></div></div></div></div></div>