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
I just created extension for GMSCameraUpdate.
input parameters:
coordinate - your center coordinate
radius - radius of visible bounds
extension GMSCameraUpdate {
static func fit(coordinate: CLLocationCoordinate2D, radius: Double) -> GMSCameraUpdate {
var leftCoordinate = coordinate
var rigthCoordinate = coordinate
let region = MKCoordinateRegionMakeWithDistance(coordinate, radius, radius)
let span = region.span
leftCoordinate.latitude = coordinate.latitude - span.latitudeDelta
leftCoordinate.longitude = coordinate.longitude - span.longitudeDelta
rigthCoordinate.latitude = coordinate.latitude + span.latitudeDelta
rigthCoordinate.longitude = coordinate.longitude + span.longitudeDelta
let bounds = GMSCoordinateBounds(coordinate: leftCoordinate, coordinate: rigthCoordinate)
let update = GMSCameraUpdate.fit(bounds, withPadding: -15.0)
return update
}
}