Change Camera Zoom based on Radius Google Maps iOS SDK

前端 未结 6 885
既然无缘
既然无缘 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:07

    For Swift 3

    extension GMSCircle {
    var bounds: GMSCoordinateBounds {
        return [0, 90, 180, 270].map {
            GMSGeometryOffset(position, radius, $0)
            }.reduce(GMSCoordinateBounds()) {
                $0.includingCoordinate($1)
        }
    }
    }
    

    Usage:

    mapView.animate(with: .fit(circle.bounds))
    

提交回复
热议问题