Getting an error trying to apply circle overlay in swift 3

76 views Asked by At

i encounter an error :

Cannot invoke initializer for type 'MKCircle' with an argument list of type '(center: CLLocationCoordinate2D,radius: int,identifier: String)'

    let region = CLCircularRegion(coder: MKCircle(center: CLLocationCoordinate2DMake(self.destLat!, self.destLong!), radius: 100, identifier: destinationAddress))
    self.locationManager .startMonitoring(for: region)

Below is my ovelay method

 func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {

   if overlay is MKCircle {
        let circleRenderer = MKCircleRenderer(overlay: overlay)
        circleRenderer.lineWidth = 1.0
        circleRenderer.strokeColor = .purple
        circleRenderer.fillColor = UIColor.purple.withAlphaComponent(0.4)
        return circleRenderer
    }

    let myLineRenderer = MKPolylineRenderer(polyline: myRoute.polyline)
    myLineRenderer.strokeColor = UIColor.blue
    myLineRenderer.lineWidth = 3
    return myLineRenderer
}
1

There are 1 answers

1
Giordano Scalzo On

Not sure what you want to do, but your declaration of region is wrong. This is the right version:

let region = CLCircularRegion(center: CLLocationCoordinate2DMake(self.destLat!, self.destLong!), radius: 100, identifier: destinationAddress)