How to display a circle in GMSMapView

后端 未结 3 2289
深忆病人
深忆病人 2020-12-15 08:16

I need to display a circle (as with MKCircle) on a GMSMapView. This is easy when using a MKMapView and MKCircle, but can\'t use MKCircle with GMSMapView. Any ideas?

3条回答
  •  一向
    一向 (楼主)
    2020-12-15 08:54

    func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {
        // Make sure cicle is a GMSCircle Object  and it is a class variable
        circle.map = nil
    
        let point = mapView.center
        circle.position = mapView.projection.coordinate(for: point)
        circle.radius = 130.0
        circle.fillColor = .clear
        circle.strokeColor = .black
        circle.strokeWidth = 3.4
        circle.map = mapView
    }
    

提交回复
热议问题