Technology

Google Maps now with KML Support

At times like these, I know that I’m a geek! Today the Google Code Blog just announced that they are now supporting KML files.

“Doug, calm down”, you say!

I can’t! I’m freakin’ out! Where you used to have to programmatically plot points on a map, you can now simply ‘point’ to a KML file and Google Maps will automatically plot it on their map.

“Yea, sure”, you say!

Here’s an example of a KML file:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<Placemark>
<name>Doug</name>
<description>Did you know they just opened Au Bon Pain right here?</description>
<Style>
<IconStyle>
<Icon>
<href>https://martech.zone/wp-content/uploads/2006/06/me2.thumbnail.jpg</href>
</Icon>
</IconStyle>
</Style>
<Point>
<coordinates>-86.158160,39.767480,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>

Using Google Maps, I simply point the map to query my KML file:
http://maps.google.com/maps?q=http://www.yourdomain.com/location.kml

“Wow”, you finally say! (I hope!)

Here’s what it looks like:
Map of Doug in Indianapolis

Seriously folks. Where XML is the universal data exchange format, KML (which is XML) is the universal geographic data exchange format. This is a great step forward. Using other GIS programs, people can output KML files and then simply open them online with Google Maps.

13 Comments

  1. 1
  2. 2

    Hi Graydon,

    Good point! I’ll update the post with instructions, open up the KML file that I have posted and you’ll see the structure. The KML file is raw text. There are also KMZ files out there. Those are KML files that are zipped up for faster transfer (if you have a huge file).

    Doug

  3. 3
  4. 4
  5. 5

    This is really awesome!

    Just wondering, why is the KML-file case sensitive. If you create the XML file with tags that have lower case starting letters. The XML/KML doesn’t work. (that’s what happend to me :D)

    • 6

      Aswin,

      I’ve noticed this as well. It’s the same with the geotag. I have no idea why they would actually impose uppercase letters in a standard. I’ve always thought it was safe for lowercase (rather than upper), but some of these services out there are really finicky.

      Thanks!
      Doug

  6. 7

    I have found a way to get this working.

    I’ve found an little freeware program (xt.exe) that works with a XSL file that can transform the not-working XML to a working KML file.

    In the XSL file (a stylesheet) provides the base of a working a xml. I can transform the lowercase tags with upper case tags. With a rename action on the working xml-file (xml to kml) you get a working kml file 🙂

  7. 8

    if for some reason you didn’t see it, the new google mymaps thingy lets you build a map and export the kml file.

    and since the google api let’s you create a map on your site built from a hosted kml file… well it all becomes easier.

Leave a Reply