Rotating Google Earth / Map around a specific point

1,203 views
Skip to first unread message

Derek S

unread,
Dec 23, 2010, 2:40:41 PM12/23/10
to KML Developer Support - Google Earth Plug-in
Hi.

Let me provide some background before I ask the question.

I have created a series of virtual tours running on Apple's QuickTime
plugin. Each location is represented by a 360 degree QTVR panorama,
and plotted on a Google map / earth plug in using very basic code.

....
map = new GMap2(document.getElementById("map_canvas"));
eval("map.setCenter(new GLatLng("+LatLng+"),14)");
map.setUIToDefault();
map.removeMapType(G_SATELLITE_MAP);
map.addMapType(G_SATELLITE_3D_MAP);
...

where LatLng is a variable containing, unsurprisingly, the coordinates
of the location.

I'm invoking Google Maps first with the option to load Google Earth so
that there is some functionality even without the Google Eart plug
installed.

This all works very nicely. I even add overlays for the route, a map,
etc.

See www.virtualmountains.co.uk/comapedrosa.


Question!

I would like to add some javascript / API to rotate the map around its
centre, such that when you look north on the QTVR, north is at the top
of the map, when the centre of the QTVR is at 45 degrees, the top of
the map is at 45 degrees.

I have studied the Google Earth and Google Maps API to find how to
achieve this functionality, but cannot find a way to.

Can any one help?

Josh L

unread,
Dec 28, 2010, 5:56:20 PM12/28/10
to KML Developer Support - Google Earth Plug-in
Hi there,

When the Google Earth Plugin is in view, you can access the full API
by using GMap2.getEarthInstance(), at which point you can manipulate
the current AbstractView (Camera or LookAt) so the orientation is
exactly what you want. See http://code.google.com/apis/ajax/playground/#move_camera
for one example of how to change the LookAt (you will probably be
interested in lookAt.setHeading more than setLatitude as used in this
example).


When in Maps, there is no directly supported method for rotating the
map, however there are some workarounds people have posted, including
a couple noted at http://googlemapsmania.blogspot.com/2010/02/rotating-google-maps.html

Hope this helps,

-Josh
Reply all
Reply to author
Forward
0 new messages