Connecting Google Maps and Google Earth by script

183 views
Skip to first unread message

cybarber

unread,
Nov 27, 2005, 10:16:06 AM11/27/05
to KML Discussions
What its all about:

Google Earth can be controlled through javascripting the API on a webpage. Linking a Google Maps implementation with Google Earth and exchanging data between the two, from ONE and the same webpage, is possible.

The point is to include the Google Earth activeX object Code:
 <object  classid="clsid:AFD07A5E-3E20-4D77-825C-2F6D1A50BE5B" id="googleEarth"></object> or 
scripted conrol var googleEarth = new ActiveXObject("Keyhole.KHInterface.1");

on the same page as the Google Maps Script control.

On ActiveX security settings: In order to get the ActiveX working, one should change the setting "Initialize and perform scripting activities for NOT marked as safe ActiveX Objects" to 'Ask' instead of 'disabled'. This way each time the page loads the question 'Allow the (possibly unsafe) ActiveX to work' will be asked. This is true for the default settings in all the Zones (Internet, Loca network and trusted sites) as all will have this setting set to disabled by default.


This way Google Earth can be controlled from the (Google Maps) webpage using GE API functions, methods and properties. Using IE's HTML+TIME behavior it is also easy to animate Google Earths interface from that same webpage (To fly to a new destination(Lat and Lon seperate), to animate the View altitude, the tilt and the azimuth(heading)).

Google Earth can also be closed by script from the webpage and will re-launch when the webpage loads.

It is possible to open files KML/KMZ/GPX from local PC. SO far I didnot succeed to open them from the Web.

Update Dec 1st: I succeeded in loading a KML file as a string from the webpage into Google Earth. That should make it very easy to do an XSLT transformation through scripting on the page an send the string result to GE using the LoadKML(string) function.
I will test that today Dec 1st.


One can take a Black and White Screen dump JPG image and save it to disc. (On the demo page, I show it in a popup and save it to C:/ with a sequential number).

One can retrieve from Google Earth the Lat/Lon, Range, Titlt and Azimuth of the current viewpoint. This data can then be used for Google Maps display. I will try to write a script which retrieves Google Earth track points and combine them to a Google Maps VML vector polyline to be displayed instantly on the Google Maps map.

Succeeded in cliking the google map and having goole Earth to fly to that point.

My demo page which can change by the minute as I work on it as we speak, is at:
Bridging GMaps and GEarth by script - a demo page by Cybarber

or can be reached through the link on attached KML.

Happy Flying,
William A Slabbekoorn aka Cybarber
212957-ControllingGEarth_GmapsbyScriptandSMIL.kml

tekgergedan

unread,
Nov 27, 2005, 12:27:16 PM11/27/05
to KML Discussions
The demo page of cybarber does not function. It contains js error.

cybarber

unread,
Nov 27, 2005, 12:34:32 PM11/27/05
to KML Discussions
I am changing it by the minute soo that can happen.
I will leave a good working version unchanged for the time being.

Sorry about that.

Cybarber

tekgergedan

unread,
Nov 27, 2005, 4:34:08 PM11/27/05
to KML Discussions
Waiting, then. It is an interesting one to me. Thanks

HookEmHorns

unread,
Nov 27, 2005, 6:04:44 PM11/27/05
to KML Discussions
It seems like a very common error that people get is the "Object doesn't support property or method" error. Whether you get this error or not and whether the JScript control works or not, seems to depend on one or all of the following:

1. What version of GE you are using
2. What web browser you are using and what version of the web browser

Of course if your security settings are too high and you're not willing to override them, things won't work properly either.

cybarber

unread,
Nov 27, 2005, 9:22:00 PM11/27/05
to KML Discussions
I have conditionally comment now all IE 5.5 and above related material sothat IE5.0 and below, Opera, Firefox and other minor browsers just get a text explaining what the page is about.

That will reduce some errors.

I have checked that one has to adjust ones activeX security settings a bit to get it working.

In order to get the ActiveX working, one should change the setting "Initialize and perform scripting activities for NOT marked as safe ActiveX Objects" to 'Ask' instead of 'disabled'. This way each time the page loads the question 'Allow the (possibly unsafe) ActiveX to work' will be asked. This is true for the default settings in all the Zones (Internet, Loca network and trusted sites) as all will have this setting set to disabled by default.



Each time the page loads one will be asked whether to activate the activeX or not. (the activeX is the Google Earth object).

I now added tracklogging with the G-force mode in Full screen. That way (even the free version users) can make a tracklog and create a path(I will develop that further to GPX/KML file) of points fo be used for....



Cybarber

Wernher

unread,
Jun 26, 2006, 7:01:13 AM6/26/06
to KML Discussions
Hello Mr Slabberkoorn

I have tried to use GE as an activeX in the way you discribed it.
Im not successfull. It is possible to create the object and to start GE but when I try to use the properties or exposed functions i get an error saying that the typelibary is not registrated.

I would be thankfull for any hint

Wernher v. Rotenhan
Reply all
Reply to author
Forward
0 new messages