Skip to main content

Making KML Simple For The iPad

I've been involved this summer in some exciting work with Development Seed on bringing their mapping technologies to the iPad. This has included their gorgeous MapBox tile sets, but also third-party data from the internet in the form of KML and GeoRSS. These are each file formats for exchanging geographic information along with content.

GeoRSS is pretty straightforward -- it's basically regular RSS but with a small amount of geographic information added in the form of extra tags such as <georss:point>. KML, however, is a completely different sort of format, written from the ground up for geographic data. It's probably most commonly known as the format that Google Earth uses to exchange geo info. Beyond Google Earth, it has been used in some exciting applications, from Development Seed's own Maps on a Stick tool to The Jane Goodall Institute's Gombe Chimpanzee Blog, which attaches KML data to every blog entry as a way to give it context and to allow the reader to explore the story a bit more.

Once I got started on the iPad work, however, I noticed that there basically was no parsing library for KML on Apple's iOS platform -- iPhones and iPads. Google puts the definitive library, libkml. It's written in C++ (a minor setback) but it also depends on libexpat, something that exists on Mac OS X but not on iOS.

That aside, I thought that it would also be nice to have a Cocoa-native KML parsing library, something that speaks in native Objective-C types like UIImage for icons and UIColor for colors without the need for conversion. So I wrote one!

This library, Simple KML, is now available as open source under the New BSD License, licensed jointly by Development Seed and Code Sorcery Workshop. You can find a basic usage overview in the features summary.

While Simple KML does make KML very simple to parse, it does not do any drawing for you. It's important to note that you will have to take the placemarks, styles, and structures in the KML documents that you wish to display and write your own drawing to display them. This could be on Apple's MapKit mapping library built into the SDK, external mapping libraries, or perhaps your own drawing on static map images. Simple KML just makes it easy to turn a KML file or a KMZ archive into data structures native to Cocoa for use in your own graphics work.

Since Simple KML is open source, I'd love to have any feedback or contributions that you might have to offer. Simple KML is up on GitHub, allowing anyone to create a free account, fork the project, and send me patches via merge requests.


(Cross-posted on the Development Seed blog)

Trackback URL for this post:

https://codesorcery.net/trackback/355