Change Camera Zoom based on Radius Google Maps iOS SDK

set zoom level google maps ios
ios google maps zoom to fit markers
gmsmapview get center coordinate
gmscameraposition swift
gmsmapview swift
move marker google maps ios swift
google maps ios move camera
google maps directions api ios swift

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 UISlider and redraw the GMSCircle.

My problem is that I want to update the camera zoom according to the slider value but I don't have an idea by which scale to divide.

This is how I create the camera in the viewDidLoad method where the initial zoom value is 15:

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:locationManager.location.coordinate.latitude longitude:locationManager.location.coordinate.longitude  zoom:15];

Here's a screenshot of what I am working on.

Does anyone know what scale should I use to move the zoom accordingly?

Thanks a lot!


With the help of Saxon Druce,finally I did it.

class MapUtil {

class func translateCoordinate(coordinate: CLLocationCoordinate2D, metersLat: Double,metersLong: Double) -> (CLLocationCoordinate2D) {
    var tempCoord = coordinate

    let tempRegion = MKCoordinateRegionMakeWithDistance(coordinate, metersLat, metersLong)
    let tempSpan = tempRegion.span

    tempCoord.latitude = coordinate.latitude + tempSpan.latitudeDelta
    tempCoord.longitude = coordinate.longitude + tempSpan.longitudeDelta

    return tempCoord

class func setRadius(radius: Double,withCity city: CLLocationCoordinate2D,InMapView mapView: GMSMapView) {

    let range = MapUtil.translateCoordinate(city, metersLat: radius * 2, metersLong: radius * 2)

    let bounds = GMSCoordinateBounds(coordinate: city, coordinate: range)

    let update = GMSCameraUpdate.fitBounds(bounds, withPadding: 5.0)    // padding set to 5.0


    // location
    let marker = GMSMarker(position: city)
    marker.title = "title"
    marker.snippet = "snippet"
    marker.flat = true = mapView

    // draw circle
    let circle = GMSCircle(position: city, radius: radius) = mapView
    circle.fillColor = UIColor(red:0.09, green:0.6, blue:0.41, alpha:0.5)

    mapView.animateToLocation(city) // animate to center


Camera and View | Maps SDK for iOS, The Maps SDK for iOS allows you to change the user's viewpoint of the map by modifying the map's The bearing, tilt, location and zoom level of the map can be controlled We "cut off" base map imagery utilizing the Mercator projection at � The Maps SDK for iOS allows you to change the user's viewpoint of the map by modifying the map's camera. Introduction. Maps added with the Maps SDK for iOS can be tilted and rotated with easy gestures, giving users the ability to adjust the map with an orientation that makes sense for them. At any zoom level, you can pan the map, or change its

Here's a simpler solution for getting the bounds of a GMSCircle. It doesn't rely on MapKit and avoids the two calls that change the camera position (moveCamera and animateToLocation)

import GoogleMaps

extension GMSCircle {
    func bounds () -> GMSCoordinateBounds {
        func locationMinMax(_ positive : Bool) -> CLLocationCoordinate2D {
            let sign: Double = positive ? 1 : -1
            let dx = sign * self.radius  / 6378000 * (180 / .pi)
            let lat = position.latitude + dx
            let lon = position.longitude + dx / cos(position.latitude * .pi / 180)
            return CLLocationCoordinate2D(latitude: lat, longitude: lon)

        return GMSCoordinateBounds(coordinate: locationMinMax(true),
                               coordinate: locationMinMax(false))

After adding this file to your project, all you have to do is:

let update =
myMap.animate(with: update)

where myCircle and myMap are replaced by the actual circle and map.

Google Maps SDK iOS - Calculate radius according zoom Level, I need calculate radius to show markers on the map according camera zoom level. Based from Release Notes made in Maps SDK for IOS, changing a markers� The maps in the Maps SDK for Android can be tilted and rotated with easy gestures, giving users the ability to adjust the map with an orientation that makes sense for them. At any zoom level, you can pan the map, or change its perspective with very little latency thanks to the smaller footprint of the vector-based map tiles. Code samples

You could use the fitBounds method of GMSCameraUpdate, passing in a GMSCoordinateBounds which is calculated from the edges of your circle.

Based on this answer, it looks like you could use MKCoordinateRegionMakeWithDistance to convert your centre (lat/lon) plus radius (metres) into a MKCoordinateRegion, which will convert the metres into a span in degrees, therefore allowing you to calculate the coordinates in degrees which you'd use to create the GMSCoordinateBounds.

Zoom into Bounds - Maps API for JavaScript, map.ViewModel to achieve the best zoom level and map centre, and then perform a custom processing on it to limit maximum zoom level. For the enablement step below, you will need to enable the Maps SDK for iOS. Set up Google Maps Platform. 1. In the Cloud Console, click the project drop-down menu and select the project that you want to use for this codelab. 2. In the Google Cloud Marketplace, enable the Google Maps Platform APIs and SDKs

For Swift 3

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


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

Set map bounds to circle bounds? (polyline, polygon, marker, circle , The user chooses a location (lat/lon) to search from and a radius. returned results, it doesn't center the map based on the initial search location, nor does it fit to the radius circle. I think I played around with changing the zoom level based on screen width ( window. Contact GitHub � Pricing � API � Training � Blog � About. Using the Maps SDK for iOS, you can listen to events that occur on the map, such as camera change events or marker tap events. Introduction. To listen to events, you must implement the GMSMapViewDelegate protocol. Typically, you implement this protocol on the view controller that displays the map. Below is an example header file:

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 =, withPadding: -15.0)

        return update


Get started with expressions using the Mapbox Maps SDK for iOS , Create a map for iOS that styles a circle based on a data attribute. on a data attribute and by zoom level. adjust the circle radius based on zoom level In this tutorial, you'll create both property and zoom expressions to conditionally change a layer's style. A data Draw custom detections using device built-in camera. The Maps SDK for iOS offers some simple ways for you to add shapes to your maps. The following shapes are supported: A polyline is a series of connected line segments that can form any shape you want and can be used to mark paths and routes on the map. A polygon is an enclosed shape that can be used to mark areas on the map.

Google maps distance based on the zoom level, Check out this question, it has answers with equations and explanations for the different zoom levels. What ratio scales do Google Maps zoom levels correspond � Find local businesses, view maps and get driving directions in Google Maps.

What ratio scales do Google Maps zoom levels correspond to , If you are designing a map you plan on overlaying over google maps or This is based on the assumption that the earth's radius is 6378137m. taken from: https ://!topic/google-maps-js-api-v3/ If you look closely you'll discover that the length of the line changes depending on the latitude of the � The Maps SDK for iOS provides a Street View service for obtaining and manipulating the imagery used in Google Maps Street View. Street View images are returned as panoramas and are viewed from within the Street View viewer — an object of type GMSPanoramaView .

Google Maps iOS SDK Tutorial: Getting Started, Learn how to use the Google Maps iOS SDK to retrieve the user's current Apple made a dramatic change and replaced Google Maps with an in-house GMSCameraPosition(target: location.coordinate, zoom: 15, bearing: 0, This updates the map's camera to center around the user's current location. google-maps-sdk-ios. Score 29. Posts 1. iphone. Score 29. 29 Change Camera Zoom based on Radius Google Maps iOS SDK Feb 7 '16. 11 Extend Google Maps marker to

  • Works great! :)
  • thnks alot buddy :-)
  • @Vlad Lego can you clarify why you have used 6378000 constant?
  • @Vignesh 6378000 is the "Radius of circle with string around Earth in meters".
  • @Vlad Lego can u give this ans in objective-c?
  • Way simpler, this should be the accepted answer! Good to mention that you can add a withPadding parameter on the .fit to change the padding. The default is 64, changed mine to 16. Thank you!
  • yes, works perfect!