I am trying to draw a semi-sphere on MKMapView knowing the center coordinates, start and end angles, and radius in nautical miles.
Using this thread(How to draw UIBezierPath overlay on MKMapView?), I have subclassed MKOverlayPathRenderer to draw an arc:
import UIKit
import MapKit
class IGAAcarsDrawArc: MKOverlayPathRenderer
{
let PI = 3.14159265
let radius : CGFloat = 10.0
var startAngle: CGFloat = 0
var endAngle: CGFloat = 3.14159
var latitude = 25.96728611
var longitude = -80.453019440000006
override func createPath()
{
let line = MKPolyline()
let arcWidth: CGFloat = 5
let path = UIBezierPath(arcCenter: CGPointMake(CGFloat(latitude), CGFloat(longitude)),
radius: self.radius,
startAngle: startAngle,
endAngle: endAngle,
clockwise: true)
path.lineWidth = arcWidth
path.stroke()
}
}
Now, it is not clear how do I use this to create MKPolyline and implement in mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay).
This thread (How to draw arc/curve line with MKOverlayView on MKMapView) does not shed too much light on the issue either.
Can someone please help draw an arc in MKMapView?
EDIT:
This is not working:
func mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay) -> MKOverlayRenderer
{
if overlay is IGAAcarsDrawArc
{
let arcLine = IGAAcarsDrawArc(overlay: overlay)
arcLine.lineWidth = 8
arcLine.strokeColor = UIColor.magentaColor()
}
return MKPolylineRenderer()
}
Thanks a lot!