簡體   English   中英

嘗試在swift 3中應用圓形疊加時出錯

[英]Getting an error trying to apply circle overlay in swift 3

我遇到一個錯誤:

無法使用類型為“(center:CLLocationCoordinate2D,radius:int,identifier:String)”的參數列表調用類型為“MKCircle”的初始值設定項

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

下面是我的ovelay方法

 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
}

不確定你想做什么,但你的region聲明是錯誤的。 這是正確的版本:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM