Once you've got time-stamped GPS information, don't rely on just
setInterval or setTimeout to manage the timing. If there are any delays,
those functions will cause the delays to accumulate and slowly cause
synchronisation to be lost.

Use Date.getTime() to get a reference time at the start and calculate
all the delays relative to that time.

For example, suppose you've just processed an event that was supposed to
happen at 5000 milliseconds, and the next event is supposed to happen at
6000 milliseconds. Don't just perform a setTimeout to delay for 1000
milliseconds.

  // Make a note of the time when the whole thing starts
  var start = new Date();

  // To schedule an event to occur at timestamp "T" ms
  var now = new Date();
  var delay = T - now.getTime() + start.getTime();
  // Check to see if we're already too late
  if (delay > 0) {
    setTimeout("nextEvent()", delay);
  } else {
    nextEvent();
  }

-- 
Mike Williams
http://econym.org.uk/gmap



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to