I’m writing a google maps v3 javascript application that fetches new markers when the bounds of the map change. For that I’m using the “bounds_changed” listener.
Problem is that I want to restrict the calls I make and don’t want to fire them every time the user changes the map viewport. How can I fire this call only if the map has been changed AND has been idle for, say, 1 second?
Thank you!
Paul
You declare a global variable for timeout
then in the event you call
what that does is clear previous call (if exists) and then add the next call to the queue, wait for 1000 milisecon (1 sec) and call it. If in 1sec some event fired, it will clear the wait queue again…
tadah