I have to change the position of a marker on Google map from a javascript function. How can I achieve that?
First off you must store the marker in an array when you create it so you can have access to it afterwards. Then change the position with marker. setPosition() as solidrevolution mentioned.
Setting a marker's draggable property to true allows the user to change the position of the marker. Use a long press to activate the ability to move the marker.
There is a method makeMarker() you just need to call from onMapReady() method . There is two method rotateMarker() and moveVechile() to rotate and move marker. Hope this will help you.
Just try to create the marker and set the draggable property to true . The code will be something as follows: Marker = new google.
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); }
First off you must store the marker in an array when you create it so you can have access to it afterwards.
Then change the position with marker.setPosition()
as solidrevolution mentioned.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With