Add KML or URL to iPhone app

I am trying to overlay a custom road design drawing (kml or dgn) on a map view in my iPhone application using the Apple KMLViewer example. I can say that he reads KML because the map scales to the borders of the drawing, and a couple of fragments of the drawing are displayed as they should be. A big hang here most of the picture is not displayed at all. The attached screenshot shows only two lines of the displayed drawing.

enter image description here

Also, check out 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 the application starting July 25 23:07:06 Michaels-iMac.local KMLViewer [2407]: ImageIO: CGImageReadSessionGetCachedImageBlockData *** CGImageReadSessionGetCachedImageBlockData: readSession [0x8434040] has bad readRef [0x8463610]

I have done a lot of research, and this seems to be a hot topic. Can I adapt KMLViewer to my KML or is there a better Apple method? I would really appreciate some advice. The more accurate, the better. Thanks in advance for your time.

+4
source share
2 answers

You can use something like the MapBox iOS SDK for display and Simple KML for parsing into Cocoa's native types. As stated above, you want to use the annotations and their views / layers provided by the map view delegate.

Another approach, if it's a static map, is to use TileMill to turn KML into a collection of fragments that you could lay on your regular map.

+1
source

I just read this thread, since I never had to draw my own routes inside MKMapView, but ...

MKPolyLine, MapKit method and protocol method MKMapViewDelegate mapView:(MKMapView *) viewForOverlay:(id < MKOverlay >) will be the solution.

Apple documentation on MKPolyLine and mapView: viewForOverlay:

Sample project

A quick example that demonstrates a common trap 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 that you did not explicitly specify Xcode, whose view controller is the initial view controller.

You need to either replace [window addSubview:[someController view]]; on

 [self.window setRootViewController:someController]; 

in applicationDidFinishLaunchingWithOptions:

or make sure your main.m indicates a suitable delegate

 retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate"); 

or (for storyboard) set the storyboard as the main storyboard in the build settings

0
source

Source: https://habr.com/ru/post/1493566/


All Articles