I'm creating an app which shows multiple overlays on a map, and you can enable or disable each 'layer'. I'm using Apple's KMLParser class as demoed in WWDC 2010 session 127.
Up till now, I've been displaying paths. When I first tried to do this, I exported direct form google earth and it didn't like it (Apple's parser likes the KML in a very specific format). So what I did was to copy the coordinates from google earth's code, to the apple one included in the KMLViewer project (keeping all the surrounding tags the same).
My question to anyone who knows - how do you do this with polygons?
Here is the google earth code for my polygon:
<Polygon>
<tessellate>1</tessellate>
<outerBoundaryIs>
<LinearRing>
<coordinates>
<!-- My Coords here -->
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
KMLParser won't display anything for that.
Just for reference, here are the differences between a google earth path and the apple-supported path:
GOOGLE EARTH:
<Placemark>
<name>A path</name>
<styleUrl>#msn_ylw-pushpin</styleUrl>
开发者_开发知识库 <LineString>
<tessellate>1</tessellate>
<coordinates>
<!-- My Coords Here -->
</coordinates>
</LineString>
</Placemark>
APPLE SUPPORTED:
<Placemark>
<name>A path</name>
<GeometryCollection>
<LineString>
<coordinates> <!-- My Coords Here --> </coordinates>
</LineString>
</GeometryCollection>
<styleUrl>#roadStyle</styleUrl>
</Placemark>
If anyone could tell me how to get KMLViewer to work with polygons that would be great!
Thanks in advance
After hours of experimenting and scouring the google docs I've figured it out:
Just for reference here is how it's done:
<Placemark>
<name>MyPoly</name>
<styleUrl>#mypolystyle</styleUrl>
<Polygon>
<outerBoundaryIs>
<linearRing>
<coordinates>
<!-- My Coords Here -->
</coordinates>
</linearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
精彩评论