Change Camera Zoom based on Radius Google Maps iOS SDK

前端 未结 6 833
既然无缘
既然无缘 2021-02-01 09:53

I am working on an app that displays certain markers based on a radius around your current location. The radius is between 100 - 5000 meters. I change the radius with an U

6条回答
  •  醉话见心
    2021-02-01 10:05

    hope it will work.

    in view controller initialise this circle

     var cirlce: GMSCircle!
    

    in viewdidload

     cirlce = GMSCircle(position: camera.target, radius: 10000)
            cirlce.fillColor = UIColor.red.withAlphaComponent(0.5)
                   cirlce.map = mapView
    

    call the delegate of googlemap

     func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {
               print(position.zoom)
            var zoom:Double = Double(position.zoom/4)
            zoom = pow(10, zoom)
            zoom = 1000000/zoom
             cirlce.radius = zoom
        }
    

提交回复
热议问题