Getting Your KML files to Open in Google Earth
A few weeks ago I posted a few neat things you can do with geo-data for your website and delved into adding KML geo files to your website. Well, I noticed one small problem. When adding a link to a KML file, on a web-page, when you click that link, the KML file just opens in the browser as any old un-styled XML file.
I was wanting these to automatically open up in Google Earth so I can watch the globe spin round and fly into the spot specified on the map. No such luck.
But I found the solution(s). One complicated, one easy.
The complicated version; You need to change some configuration settings on your server to tell browsers that the kml file type should go and launch Google Earth. Google mentions how to tell an Apache or Windows server what kind of file types they are serving. For most using shared hosting accounts you wont have access to the config files of the server. You can however ask your host if they could do the switch for you.
The easy way; Convert that KML file into a KMZ. The .kmz extension is basically a zipped version of the KML. An easy way to produce the zipped version is to simply zip it using something like WinZip or WinRar. Now it will have a .zip extension. Save it to your server then simply rename the file to a .kmz extension. It’s that simple.
Simply link directly to the KMZ file on your webpage. When a user who has Google Earth installed on their computer clicks the link the GEarth software should open up and zoom to the location in that file.
So this was my KML file. As you see it just opens it up as XML. Pleh!
Now this is the version that will open up in Google Earth.
Put the KMZ on your web page where visitors can make use of it and place the KML version in your site map so Google can index it. I’m not sure yet if Google bot is capable of unzipping the contents of a zipped file so let them find the full KML too.
3 Comments to “Getting Your KML files to Open in Google Earth”
Leave a Comment
RSS Feed

The Topics
- I’m Such a Nerd - Now a Wine Nerd
- An Ode to a Very Special Little Rescue Dog
- Centering a Div in IE9 Using margin:auto
- Playing with HTML5 for First Time
- My Wife is a Food Blogger
- Designing and Coding a Mobile Version of your Website
- A CSS Sticky Footer that Works in 2009 (Chrome too) (343)
- New iGoogle with Left Nav Bar is the SUCK! (194)
- My Cool Ass CB750 Cafe Racer (115)
- Centering a Div in IE8 Using margin:auto (19)
- The State of Local Search in Canada (14)


Recent Stuff

It turns out “the easy way” only works in FireFox. Internet Exploder still needs to be told by the server the MIME type for the file so it can pass the file over to Google Earth.
i jst want to embbed the google earth in my web page. and want to import the kml file if i press a button from my web page like import to google earth. now the kml file should jst open in the google earth
Really useful, wanted to link in a bunch of locations into google maps, not google earth. Unfortunately it does not support kml, so need to convert to kmz and upload the same.
Thanks a ton !
Cheers,
Vikram.
http://piglings.blogspot.com