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.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BlinkList
  • Furl
  • Propeller
  • Slashdot
  • StumbleUpon
  • Technorati


DoFollow links available for frequent commentors.

3 Comments to “Getting Your KML files to Open in Google Earth”

Stever on June 25th, 2008 wrote:

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.

rajiv on November 30th, 2008 wrote:

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

Vikram (1 comments.) on November 3rd, 2009 wrote:

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

Leave a Comment