How to draw a MKPolyline on a MapView?

前端 未结 3 1367
轻奢々
轻奢々 2020-12-14 16:27

I have an array of points to be drawn on a map, its already decoded:

- (void) drawRoute:(NSArray *) path {
    NSInteger numberOfSteps = path.count;

    CLL         


        
相关标签:
3条回答
  • 2020-12-14 16:33
    MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coordinates count:self.allPins.count];
    [self.mapView addOverlay:polyline];
    

    Check this http://pinkstone.co.uk/how-to-draw-an-mkpolyline-on-a-map-view/ and for swift http://rshankar.com/how-to-add-mapview-annotation-and-draw-polyline-in-swift/

    0 讨论(0)
  • 2020-12-14 16:43

    Just create MKPolyline with coordinates & add that polyLine to map view.

    MKPolyline *polyLine = [MKPolyline polylineWithCoordinates:coordinates count:numberOfSteps];
        [map addOverlay:polyLine];
    

    You will find an tutorial here on how to draw polyline over some coordinates. Edit: The url does not seems valid anymore. You can find the archived version of this url here.

    0 讨论(0)
  • 2020-12-14 16:52

    Done.

    Was a very stupid thing, i didn't set the delegate for the MapView. Simply adding [map setDelegate:self]; did the trick.

    Thank you anyway!.

    0 讨论(0)
提交回复
热议问题