Play, pause and resume google maps markers

138 views
Skip to first unread message

Anush

unread,
Jun 8, 2011, 9:16:59 PM6/8/11
to google-map...@googlegroups.com


I am trying to add external controls to play, pause and resume loading of google markers. I used setTimeout to load markers with a delay. But can somebody tell me where should I using clearTimeout to pause loading of google markers? Using it in a separate function didn't work for me.

 for (var i = 0; i < all_markers.length; i++) {
          t2 = setTimeout(function(){
               addMarker();
          },i * 300);
   }

   function pauseAnimation(){
        clearTimeout(t2);
   }

Thanks

geoco...@gmail.com

unread,
Jun 9, 2011, 12:41:31 AM6/9/11
to Google Maps JavaScript API v3
On Jun 8, 6:16 pm, Anush <anushshe...@gmail.com> wrote:
> **
What do you think that loop is doing?

To me it looks like it is creating all_markers.length timers,
overwriting t2 with the latest one created, leaving it set to the last
one.

The pauseAnimation function will only cancel the last one.

-- Larry

>
> Thanks
Reply all
Reply to author
Forward
0 new messages