I was looking for a good solution for marker animation using the Google Maps JavaScript V3 API. The marker will animate along a predefined path defined using latitude and longitude coordinates.
For all the research I have done, I still cannot find a solution compatible with version 3 of the Google Maps API API. Looking at this earlier StackOverflow post, apparently, it was possible to animate using version 2 of the API using GRoute and setting the marker to points along the route using a timer.
Here is the code that was previously offered. I understand how this works logically, but I have no idea how this can be ported to work with version 3 of the Google Maps API:
function moveToStep(yourmarker,yourroute,c) { if {yourroute.getNumSteps() > c) { yourmarker.setLatLng(yourroute.getStep(c).getLatLng()); window.setTimeout(function(){ moveToStep(yourmarker,yourroute,c+1); },500); } } moveToStep(marker,route,0);
There is no mention of GRoute , getNumSteps (which, I believe, returns the number of coordinates defined on this route, setLatLng (I believe that it receives the latitude and longitude coordinates of the marker) or moveToStep (which actually moves the marker) in version 3 full documentation and link .
It seems that Google has completely rewritten the API from version 2 to version 3, as these functions (which seem pretty basic) have all been either removed or renamed (I'm not sure which one).
The only mention of animations I've ever seen in version 3 of the JavaScript API was for animating markers when they first appeared on the map, making them either BOUNCE or DROP . However, they actually do not move the latitude / longitude coordinates of the marker, but simply the way they are located on the map. These two marker animations are mentioned in the API link here .
See the same StackOverflow column above for a link here .)
Ultimately, I think I have two questions:
1: is it possible to animate markers along a given path using the Google Maps V3 API?
and if not, then
2: Will I be forced to use an outdated library to achieve this or are there other well-known solutions?
Thanks so much for any input that can help solve this problem!