MapKit 叠加 - 圆形
MapKit Overlays - Circles
我正在尝试向地图添加一个圆形叠加层,但从未成功 - 添加了注释,仅此而已
这是代码示例
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer
let circle = MKCircleRenderer(overlay: overlay)
circle.fillColor = UIColor.black.withAlphaComponent(0.1)
circle.strokeColor = UIColor.red
circle.lineWidth = 9
return circle
}
let circle = MKCircle(center: coordinates, radius: 9000)
mapView.addAnnotation(Loka_Location)
mapView.addOverlay(circle)
您可能错过了设置 mapView 的委托。
mapView.delegate = self
别忘了
class ViewController: UIViewController, MKMapViewDelegate {}
我正在尝试向地图添加一个圆形叠加层,但从未成功 - 添加了注释,仅此而已 这是代码示例
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer
let circle = MKCircleRenderer(overlay: overlay)
circle.fillColor = UIColor.black.withAlphaComponent(0.1)
circle.strokeColor = UIColor.red
circle.lineWidth = 9
return circle
}
let circle = MKCircle(center: coordinates, radius: 9000)
mapView.addAnnotation(Loka_Location)
mapView.addOverlay(circle)
您可能错过了设置 mapView 的委托。
mapView.delegate = self
别忘了
class ViewController: UIViewController, MKMapViewDelegate {}