Animated Zoom? (Like, panTo() only in zoom level?)

9,825 views
Skip to first unread message

Kivak

unread,
Jun 30, 2011, 1:40:33 PM6/30/11
to Google Maps JavaScript API v3
Hello everyone!

I am trying to make a little animated intro to my map where, for
instance, you start at zoom level 4 and go to zoom level 17. Is there
a way to do that in Javascript?

I know there is a panTo() function, but I haven't found anything that
does the same for altitude.

Thanks a bunch!
-Kivak

Kivak

unread,
Jun 30, 2011, 2:59:49 PM6/30/11
to Google Maps JavaScript API v3
Alright, I found the post about the API changes to only make the zoom
animation for a change of a maximum of 2 zoom levels. And it also
appears that people aren't happy with the change. I was hoping there
was a method in the API to do this, but apparently I have to force the
Javascript to do it (Unless someone has a better idea).

I set my script up like this:

function initialize() {
...
// Start the countdown for the zoom in animation
setTimeout("zoomIn()",INITIALZOOMDELAY);
...
}

function zoomIn() {
if( map.getZoom() < ENDZOOM ) {
map.setZoom(map.getZoom() + ZOOMINCRIMENT);
setTimeout("zoomIn()", ZOOMFACTOR * 100);
}
}

I have constants defined for the following:
// Zoom Animation
INITIALZOOMDELAY = 5000; // Number of Millisecond Delay
BEGINZOOM = 10; // Begin Zoom Level
ENDZOOM = 17; // End Zoom Level
ZOOMINCRIMENT = 1; // 1 or 2 only, 1 Slower(smooth animation), 2
Faster(rough animation)
ZOOMFACTOR = 2.0; // 2.0 - 0.1 (Slower (rough animation), Faster
(smooth animation))

Where INITIALZOOMDELAY is used in the creation of the map and is set
as the map's initial zoom.

Hope this helps someone! And I am open to any other ideas people might
have!!

-Kivak

Chris Broadfoot

unread,
Jul 4, 2011, 1:11:11 AM7/4/11
to google-map...@googlegroups.com
Unfortunately there's no good solution to this at the moment. Because tiles are loaded on demand, it's hard to smoothly animate between many zoom levels.

--



--
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 google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


br0k3n

unread,
Jul 23, 2011, 4:47:17 AM7/23/11
to Google Maps JavaScript API v3
Hi,
Someone can share a working example of this (the constants and the
functions mentioned in an answer earlier or for other complete code
example)?
i want to zoom in and zoom out for every marker found on the map of
Google earth plugin.
lets say i have 6 points on the map - how can i do a loop that zoom in
to the point than zoom out to more higher view of the world and than
zoom in to the next point in a loop again and again.
thank you!

On Jul 4, 8:11 am, Chris Broadfoot <c...@google.com> wrote:
> Unfortunately there's no good solution to this at the moment. Because tiles
> are loaded on demand, it's hard to smoothly animate between many zoom
> levels.
>
> --http://twitter.com/broady

geoco...@gmail.com

unread,
Jul 24, 2011, 8:39:58 AM7/24/11
to Google Maps JavaScript API v3
On Jul 23, 4:47 am, br0k3n <nttbro...@gmail.com> wrote:
> Hi,
> Someone can share a working example of this (the constants and the
> functions mentioned in an answer earlier or for other complete code
> example)?

What about Chris' reply was unclear?
+ Unfortunately there's no good solution to this at the moment.
Because tiles
+ are loaded on demand, it's hard to smoothly animate between many
zoom
+ levels.

-- Larry

Martin™

unread,
Jul 24, 2011, 1:02:49 PM7/24/11
to Google Maps JavaScript API v3
Let me add to that...

If the map user has browsed to an area of the map (either in the
current session or previously) then their browser cache will have the
tiles for that area in their browser cache.
A smooth animated zoom MAY be possible.

Otherwise the smoothness of any attempt at an animated zoom will be
entirely dependent upon how fast the user's computer can fetch the
tiles.

Network speed being beyond the control of the developer!

Martin.



On Jul 24, 1:39 pm, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages