Zoom in and Zoom out animation in Google earth.

117 views
Skip to first unread message

br0k3n

unread,
Jul 23, 2011, 5:06:17 AM7/23/11
to Google Earth API
Hi,

there's some info found on this in the "Google Maps JavaScript API v3"
google group:
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/2cf332a6b00f4575/0921842c9d4ff75f?lnk=gst&q=zoom#0921842c9d4ff75f

i wanted to know if you have an idea how can i zoom in and zoom out in
animation for every marker found on the map on google earth (web page
that viewed in the browser using Google earth plugin).

for example i have 6 markers on the map, i want to do a loop that zoom
in and zoom out between those points.
i want to do a loop that zoom in to the first point or marker, than
zoom out for more higher view point of the world and than zoom in to
the next point and than zoom out. this has to be done for all the
markers found in a loop.

do you have a working code example or a reference you can share?

thanks!

Paul van Dinther

unread,
Jul 23, 2011, 5:14:57 AM7/23/11
to google-e...@googlegroups.com

Yep perfectly doable.  I can cut the code for you.  You can see what I do on planetinaction.com send me an email if you are interested.

> --
> You received this message because you are subscribed to the Google Groups "Google Earth API" group.
> To post to this group, send email to google-e...@googlegroups.com.
> To unsubscribe from this group, send email to google-earth-a...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-earth-api?hl=en.
>

ntt broken

unread,
Jul 23, 2011, 10:14:23 AM7/23/11
to google-e...@googlegroups.com
i don't understand how to refer the map loaded in the google earth plugin and how to get and set the zoom level.
maybe this will help to understand - for example i have those 2 function in the webpage:

      function init() {
         google.earth.createInstance('map3d', initCB, failureCB, { 'language': 'en' });
      }

      function initCB(instance) {
         ge = instance;
         ge.getWindow().setVisibility(true);
ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);  
 
google.earth.fetchKml(ge, 'http://www.mydomain.com/file.kmz', kmlFinishedLoading);
      }

i don't know how to refer the map3d to have it zoom in and zoom out.
should it be:
map3d.setZoom(14);
or
google.earth.zoomTo(google.earth.map3d.getZoom() + 3);
or should i use the ge.getZoom() ...

i tried few options but nothing seem to work.
also, i don't know where the code that will handle the zoom in and zoom out should be located - in what function?

thank you.

br0k3n

unread,
Jul 23, 2011, 10:27:36 AM7/23/11
to Google Earth API
i have also tried with the info found here which seems to be relevant:
http://code.google.com/apis/earth/documentation/camera_control.html

Zooming the camera:
Zooming in and out is controlled by the range attribute for LookAts,
and the altitude attribute for Cameras.
Note that changing the altitude attribute of a LookAt changes the
altitude of the point being viewed. Because the viewer range is
relative to this point, the viewer's altitude is also changed.

Lookout:
// Get the current view
var lookAt =
ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);

// Zoom out to twice the current range
lookAt.setRange(lookAt.getRange() * 2.0);

// Update the view in Google Earth
ge.getView().setAbstractView(lookAt);

Camera:
// Get the current view
var camera =
ge.getView().copyAsCamera(ge.ALTITUDE_RELATIVE_TO_GROUND);

// Zoom out to twice the current distance
camera.setAltitude(camera.getAltitude() + 5000);

// Update the view in Google Earth
ge.getView().setAbstractView(camera);

but again, i don't know how and where to use it in my code with the
map initialized with:
google.earth.createInstance('map3d', initCB, failureCB, { 'language':
'en' });




br0k3n

unread,
Jul 23, 2011, 10:37:30 AM7/23/11
to Google Earth API
sorry for all the threads opened.
when i try to use the following code or other code samples from the
link of "Cameras" i'm getting for getView()
the error "Uncaught TypeError: Cannot call method 'getView' of
undefined".
i guess when i solve this thing i will be able to use and change
camera, zoom in and out....

// Get the current view
var lookAt =
ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);

// Set new latitude and longitude values
lookAt.setLatitude(36.584207);
lookAt.setLongitude(-121.754322);

// Update the view in Google Earth
ge.getView().setAbstractView(lookAt);



br0k3n

unread,
Jul 24, 2011, 7:18:12 AM7/24/11
to Google Earth API
an interesting point.
can i do via javascript code zoom in and zoom out etc after i loaded
KML file to the google earth plugin?
for example after using the data file with this line of code:
google.earth.fetchKml(ge, 'http://www.mydomain.com/file.kmz',
kmlFinishedLoading);
can later use on the map the code:
var lookAt =
ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
lookAt.setLatitude(36.584207);
lookAt.setLongitude(-121.754322);
ge.getView().setAbstractView(lookAt);
> > > thank you.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages