1

I am using KMLParser library for offline map to download .kml file from server but I found these warnings.

Please give any solution to remove these warnings.

Here is function for both:

for initWithPolygon,

- (MKOverlayPathView *)createOverlayView:(MKShape *)shape
{
    // KMLPolygon corresponds to MKPolygonView

    MKPolygonView *polyView = [[MKPolygonView alloc] initWithPolygon:(MKPolygon *)shape];
    return polyView ;
}

for initWithPolyline,

- (MKOverlayPathView *)createOverlayView:(MKShape *)shape
{
    // KMLLineString corresponds to MKPolylineView
    MKPolylineView *lineView = [[MKPolylineView alloc] initWithPolyline:(MKPolyline *)shape];
    return lineView ;
}
crazydev
  • 103
  • 1
  • 1
  • 9
  • 1
    See the [documentation](https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKPolygonView_class/#//apple_ref/occ/instm/MKPolygonView/initWithPolygon:) for `initWithPolygon:`. Read the Deprecation Statement which says to use an `MKPolygonRenderer` object instead. –  Jan 16 '15 at 13:25
  • possible duplicate of [MKPolylineView initWithPolyLine: is deprecated in iOS 7](http://stackoverflow.com/questions/28276383/mkpolylineview-initwithpolyline-is-deprecated-in-ios-7) – MSU_Bulldog Aug 28 '15 at 14:24
  • The question then becomes, how do we access things like .layer in the renderer? Like to rotate the polygon and such? Did they entirely remove the CALayer stuff from MKPolygon and MKPolyline? – DrRocker Sep 25 '15 at 14:48

1 Answers1

2

You should use (MKOverlayRenderer *) type delegate instead of (MKOverlayView *) type delegate. And return MKPolylineRenderer instead of MKPolylineView.

- (MKOverlayRenderer *)mapView:(MKMapView *)mapView
           rendererForOverlay:(id<MKOverlay>)overlay {
   MKPolylineRenderer *renderer = [[MKPolylineRenderer alloc] initWithOverlay:overlay];
   renderer.strokeColor = [UIColor blueColor];
   renderer.lineWidth = 2.0;            
   return renderer;
}
Hemang
  • 26,840
  • 19
  • 119
  • 186