Reputation: 377
I'm trying to overlay a custom drawing of a roadway design (kml or dgn) to a map view in my iPhone app using Apple's sample KMLViewer. I can tell it's reading the KML because the map zooms to the bounds of the drawing and a couple fragments of the drawing are displayed as they should be. The big hang up here is most of the drawing does not display at all. The attached screen shot shows just two lines of the drawing being displayed.
Also, please review the debug log here:
2013-07-25 23:07:06.597 KMLViewer[2407:c07] Application windows are expected to have a root view controller at the end of application launch Jul 25 23:07:06 Michaels-iMac.local KMLViewer[2407] : ImageIO: CGImageReadSessionGetCachedImageBlockData *** CGImageReadSessionGetCachedImageBlockData: readSession [0x8434040] has bad readRef [0x8463610]
I've done a lot of research and this seems to be a hot topic. Can I adapt the KMLViewer to my KML or is there a better Apple method? I'd greatly appreciate some advice. The more specific the better. Thanks in advance for your time.
Upvotes: 4
Views: 1630
Reputation: 3456
I have only read around this subject since I've never actually had the need to draw my own routes inside an MKMapView but...
MKPolyLine, a MapKit class and the MKMapViewDelegate protocol method mapView:(MKMapView *) viewForOverlay:(id < MKOverlay >)
will be the the way to a solution.
Apple's documentation on MKPolyLine and mapView:viewForOverlay:
A quick example, showcasing a common pitfall when learning to draw MKPolyLines
Edit
23:07:06.597 KMLViewer[2407:c07] Application windows are expected to have a root view controller at the end of application launch
is because you haven't explicitly told Xcode which view controller is the beginning view controller.
You either need to replace [window addSubview:[someController view]];
to
[self.window setRootViewController:someController];
in applicationDidFinishLaunchingWithOptions:
or make sure your main.m specifies the proper delegate
retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
or (for storyboards) set your storyboard as the main storyboard in Build Settings
Upvotes: 0
Reputation: 5128
You could use something like the MapBox iOS SDK for the display and Simple KML for the parsing into native Cocoa types. They as mentioned above you want to use annotations and their views/layers provided by the map view delegate.
Another approach, if this is a static map, is to use TileMill to render the KML into a set of tiles that you could overlay onto your regular map.
Upvotes: 1