At the beginning of the script, add a global variable:
var jStop = false;
Then, change the last line of function animate(d) from
setTimeout("animate("+(d+step)+")", tick);
to
if (!jStop) {
setTimeout("animate("+(d+step)+")", tick);
}
Next, add a new function to the script:
function stopAnimation() {
jStop = true;
}
And at last a button with which you can trigger it:
<input type="button" onclick="stopAnimation()" value="Stop!" />
That's it! The animation will stop when you'll click on the button.
But on a side note, this example uses Maps API V2. This is the Maps API V3
group :)
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" 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-js-api-v3?hl=en.