Question

So, I've got a class with contains a NSMutableArray of CLLocation's, and a name.

Now I want to save them to KML, ideally as a track (or , so I can use the file to display the locations traveled.)

How would I go about this?

I don't expect code, more guidance (I'm new to Objective-C and KML, so got a lot to learn! :) )

Was it helpful?

Solution

I haven't used either of these, but here's a couple of libraries that turned up in a search:

http://github.com/incanus/Simple-KML/

http://developmentseed.org/blog/2010/aug/12/kml-parsing-library-released-apples-ios-platform

Edit: it looks like both those libraries are parsers, not writers. You may have to create your own writer.

I'd say that using either of these libraries would save you a lot of time. That said, have a look at how KML is formed. It's just XML and making a track is really easy. Here's an example:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1" xmlns:trails="http://www.google.com/kml/trails/1.0">
  <Document>
    <name>RK_Running.kml</name>
    <Placemark>
      <name>Running 12/9</name>
        <Style>
          <LineStyle>
            <color>ff0000ff</color>
            <width>4</width>
          </LineStyle>
        </Style>
      <MultiGeometry>
        <LineString>
          <tessellate>1</tessellate>
          <coordinates>
138.968309,35.716577,17.0
138.967998,35.716859,17.0
138.967526,35.717252,20.0
138.967055,35.717494,20.0
          </coordinates>
        </LineString>
      </MultiGeometry>
    </Placemark>
  </Document>
</kml>

Save this as a .kml and it will open in Google Earth

OTHER TIPS

KML is just XML. I'd suggest you create something like what you're looking for using Google Earth. Save it as KML and open it with a text editor to get an idea of what you need to output.

You can generate XML using libxml2 or KissXML

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top