问题
I am developing an iOS app that displays KML data over an MKMapView.
Apple's KMLViewer sample app has gotten me started. Unfortunately, the KML data I am using relies heavily on linked files via the NetworkLink
, Link
and href
KML elements, and KMLViewer's parser doesn't handle those.
I can probably figure out how to add such support, but before I go down that road I was wondering if anyone else has already done this, or if there is a better starting point than KMLViewer.
I've looked at Simple KML, but it doesn't seem to support NetworkLink
either.
回答1:
Here's how my investigations went:
- I first extended the KMLViewer sample to support the additional elements I needed. The sample is not well suited to this: it is not organized the way a SAX-style parser should be, and the simplistic state machine really needs an overhaul if you want to add more stuff to it.
- Next I tried the Simple KML library. It was easy to use, but it took 3500 milliseconds to parse the KML file I needed to parse, which was at least 3000 milliseconds longer than I would find acceptable. Also, Simple KML didn't support all the elements and attributes I needed, so I would have needed to extend it if I wanted to use it.
- So, I finally just used TBXML, which was easy to use and which parsed the file in less than 100 milliseconds.
来源:https://stackoverflow.com/questions/5248021/extending-ios-kmlviewer-sample-to-handle-kml-networklink-elements