I’ve a set of array.
var markers = [
{ lat: 1.55851, lng: 103.63217, name: "Bus A" },
{ lat: 1.56525, lng: 103.63487, name: "Bus B" },
{ lat: 1.55843, lng: 103.64669, name: "Bus C" },
];
How do I change the lat and lng value every 10 second? Maybe I get the value from another set of array and assign to lat and lng every 10 sec.
The crux of your answer would be to use
setInterval, which runs a block of code at regular intervals.In your case you might do something like:
This will invoke the function every 10 seconds. So you’d need to write a body for the function which would change your
markersvalues to whatever you want (presumably the current values according to “another set of arrays”). And then this would work, as your function would run regularly and keepmarkersup to date.