I’m trying to move a single marker along a route with a function. I tried to declare the marker in the global scope but it doesn’t seem to work… my other global variables do…
var marker = new google.maps.Marker({map: map});
function playTrip(i) {
if (i < numRows) {
var lat_value = data.getValue(i,3);
var lon_value = data.getValue(i,4);
var loc = new google.maps.LatLng(lat_value, lon_value);
marker.setPosition(loc);
i++;
setTimeout("playTrip("+(i)+")",20);
}
}
It is possible to use global variable to store the marker and map also.
Here is code which will dynamically change the map and marker location.
i have created a page here