How to change the position of marker from a javascript function?

Saurabh picture Saurabh · Apr 28, 2011 · Viewed 99.2k times · Source

I have to change the position of a marker on Google map from a javascript function. How can I achieve that?

Answer

solidrevolution picture solidrevolution · Apr 28, 2011

You can use setPosition function of the marker class

function changeMarkerPosition(marker) {
    var latlng = new google.maps.LatLng(-24.397, 140.644);
    marker.setPosition(latlng);
}