![](/img/trans.png)
[英]I am trying to add an overlay circle to my map using MapKit in Swift Xcode. But, the overlay is not showing up
[英]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.