How to add a Google Earth link on to a web page
If you have a website, it may be possible to add a link to open Google Earth and 'fly to' a specific place. It can also set the viewing angle too.
This is a simple tutorial on ‘How To’. For the purposes of the tutorial, the selected location is one of the Shuttle launch pads at Cape Kennedy, Florida, USA.
The process consists of:
A) Capturing the geographic location as a file;
B) Converting the resulting *.KMZ file into a *.KML file
C) Minor edit of the *.kml file
D) Creating a link on the web page.
E) Uploading the kml file to your server
A) Capturing the KMZ file for your location:
a1) Open Google Earth and find your location. Zoom in, rotate and set the angle of view to your needs.
a2) Click the Mail ICON in the tool bar above the map.

Fig1
a3) Select Snapshot of 3D View (the middle option), then click on the Email button.
Fig2
This will open up your email software. (You don’t need to actually send the email – see next step)
In this example, the email software is Outlook 2007

Fig3
a4) In the email software, locate the ‘attachment’ that will be labelled GoogleEarth_Placemark.kmz. Right click on it and copy it to memory.

Fig4
a5) With Windows Explorer, create a directory such as GE KMZ and Paste the copied kmz file therein. (Do not close the email client until you have pasted the attachment.)
a6) For convenience sake, rename the file to something meaningful (as in this case cape-kennedy.kmz) You can now close the email software because you don’t need to email it to anyone.
B) Converting the KMZ to a KML file:
The KMZ file is an ordinary zip file and needs to be unzipped. Easily done…
b1) Simply rename the extension from *.kmz to *.zip (Ignore the warning that you will get!)
b2) Unzip the file and locate the resulting doc.kml (Do not double click on this yet…)
b3) Rename doc.kml to something meaningful (cape-kennedy.kml)
C) Minor edit of KML file:
c1) open the kml file in a text editor.

Fig5
c2) on the 4th line you will see ~GE5A.kmz …
c3) … Change this to something meaningful – (our case ~Shuttle Home
c4) then on about line 34, find GoogleEarth_Placemark …
c5) … Change this also (in our case Shuttle Launch Pad
c6) Save the file with these 2 minor edits.
c7) Upload this file on to your server. (say into a directory: kml)
D) Creating a link on the web page
The link is exactly the same as any other standard html link.
Two samples:
Sample 1) Space Shuttle Launch Pad
Sample 2) 
Sample 2 is a clickable image link. It assumes that there is a .gif image 94x100 pixels. Obviously the image name & dimensions will need to be changed to suit your own specific needs.
Upload the page and away you go…
Testing the link and uploaded kml file
Test the link in separate browsers especially in IE and Firefox…Not all host servers are configured to parse a kml or kmz file and act as an ‘Earth Browser Server’.
If, when you click on the link, you get a page open up and see the code/script that your host browser is not configured to do so…
Solution 1 – a work-around for Internet Explorer. Open the kml file and delete the first line:
Save and upload to server - This should now work in Internet Explorer. It will not work with Firefox
Solution 2 – The preferred solution:
Contact the Systems Administrator at your hosting company. Explain what you are trying to achieve and point him to the Official Google Earth statement:
| KML MIME Types When responding to a request from Google Earth (or any Earth browser), a KML server must follow a certain set of rules so that Google Earth can correctly interpret its responses. Upon success, the server must return a response code of HTTP 200 and set the response's content-type to a suitable MIME type, as described here. Google Earth reads KML and KMZ files. The MIME type for KML files is • application/vnd.google-earth.kml+xml The MIME type for KMZ files is • application/vnd.google-earth.kmz For Apache, add these lines to the httpd.conf file: • AddType application/vnd.google-earth.kml+xml .kml • AddType application/vnd.google-earth.kmz .kmz See the Microsoft documentation for details on setting up MIME types on Microsoft's IIS. * The body of the response must contain valid KML data, including the XML declaration (). If the server returns invalid KML, the Network Link will stop, deactivate, and output an error message. |
* http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/eb5556e2-f6e1-4871-b9ca-b8cf6f9c8134.mspx?mfr=true
Tip: the default setting on Google Earth has all the ‘Geographic Web’ content switched on. This clutters the screen with all sorts of distractions. You can switch most of them off in one fell swoop. Just un-tick Geographic Web.
You can test the Google Earth link here:
Google Earth Space Shuttle Pad
© 2010 techsupportforum.com




del.icio.us
Digg