Update: this information is now out of date because of improvements to the KML format in version 2.2. You can read about this in a later post and in Google’s great tutorial on extended data.
Recently, Chris over at FortiusOne has written a couple articles, focusing largely on the Schema tag in KML. One thing in particular from this article got me thinking:
Google Earth will display your custom fields in the markers that get displayed in a Schema-based KML file, but itâ€™s still up to you to make a pretty-looking description if you want, and if you want to include some of the data in your custom fields, youâ€™ll have to duplicate the information which isnâ€™t ideal.
This certainly seems like a bit of a roadblock for the good old Schema tag. It really breaks the whole separation of content from style idea, which surprised me because this separation had been accommodated in other KML tags. So I started hacking… and found that this isn’t really a limitation. One word: BalloonStyle.
Using this tag, you can easily use Schema to transport relatively pure attributes, while pointing to style information located elsewhere in the document or, if you’re in the mood, in a different document entirely.
Here’s some data in a relatively simple schema:
<newt_breed>Common Orange Slitherer</newt_breed>
Which can be combined with the following BalloonStyle:
<td colspan="2"><img src=
To give you the fully separated content/style shown below:
Now, I think that’s downright cool. I can have my cake and eat it too. If you want to see this example live in Google Earth ™, just click on the image above. You can also view the source of the content document, or of the style document. I’ll leave it as an exercise for the reader to determine whether this technique can be used with more complex tags than SimpleField, such as SimpleArrayField and ObjField :)
I am aware of one other application (Safe Software’s FME) that is using the Schema tag to pass around attributes, and have really liked the idea ever since I first saw it in Rebecca Moore’s anti-logging KML file. It’s easy to use, doesn’t require external documents, and combined with other KML goodness allows you to pack styling around with your fully attributed data.
There is a nasty rumour floating around that Schema has been deprecated. It isn’t listed as such in the KML docs yet, and I certainly hope that it isn’t too late to ensure continued support for this handy tag from Google.