
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:
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.
You make it sound great… just point me in the direction of how to make a kml file and I might just fully agree…
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
That is SO cool! What will they think of next?
One note I forgot to mention is that the KML file can also be prepared or opened with Google Earth as well, a free GIS desktop application! You can download the latest beta here:
http://earth.google.com/
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)
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
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 🙂
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.