TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Apr 2016 |
Maintained by Nick Blackwell.
An ultra simple SAX kml parser - great for large kml files
To run the example project, clone the repo, and run pod install
from the Example directory first.
#import "Kml.h"
//...
-(void) someKmlIntializer:(NSString *) kmlText{
NSString *kmlString=@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><kml xmlns=\"http:/www.opengis.net/kml/2.2\"><Placemark><name>Descriptive HTML</name><visibility>1</visibility><description><![CDATA[]]></description><Point><coordinates>-122.0822035425683,37.42228990140251,0</coordinates></Point></Placemark></kml>";
Kml *kml =[[Kml alloc] initWithKmlString:kmlString];
[kml onPlacemark:^(NSDictionary *dictionary) {
//NSLog(@"%@", dictionary);
}];
[kml parse];
}
#SomeViewController.h
...
#import "SaxKmlParserDelegate.h"
@interface SomeViewController : UIViewController<SaxKmlParserDelegate, ...>
...
#SomeViewController.m
...
-(void) someKmlIntializer:(NSString *) kmlText{
[[[SaxKmlParser alloc] initWithDelegate:self] parseString:kmlText];
}
-(void) onKmlPlacemark:(NSDictionary *)dictionary{
//TODO add to MKMap
}
-(void) onKmlGroundOverlay:(NSDictionary *)dictionary{
//TODO add to MKMap
}
-(void) onKmlPolyline:(NSDictionary *)dictionary{
//TODO add to MKMap
}
-(void) onKmlPolygon:(NSDictionary *)dictionary{
//TODO add to MKMap
}
...
KMLSaxParser is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "KMLSaxParser"
nickolanack, [email protected]
KMLSaxParser is available under the MIT license. See the LICENSE file for more info.