Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw arc/curve line with MKOverlayView on MKMapView

Help needed now. I can draw lines with MKPolyline and MKPolylineView, but how to draw an arc or curve lines between two coordinates on the MKMapView? Great thanks.

like image 567
Shiny Avatar asked Apr 15 '11 06:04

Shiny


2 Answers

Reading the documentation, it seems that you can create an instance of MKOverlayPathView and assign an arbitrary CGPathRef object to its path property. This path can contain both straight lines and arcs.

I don't know (and the documentation doesn't mention) in what format the coordinates of the path should be (MKMapPoint or CLLocationCoordinate2D come to mind) but you can probably find that out by experimenting a bit.

like image 176
Ole Begemann Avatar answered Sep 18 '22 11:09

Ole Begemann


You answered yourself in your comment already, but I'd like to point everyone at the excellent AIMapViewWrapper project on GitHub which includes sample code for plotting an arc path over a set of coordinates. In that project it's being used to draw the path a plane takes including a shadow path underneath it (and other stuff such as animating a plane along that path). Should come in handy for anyone taking a stab at this.

like image 38
Adrian Schönig Avatar answered Sep 19 '22 11:09

Adrian Schönig