A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/maps/documentation/navigation/ios-sdk/camera below:

Adjust the camera | Navigation SDK for iOS

Adjust the camera

Stay organized with collections Save and categorize content based on your preferences.

The camera allows you to change the user's viewpoint of the map. You can use camera modes to control the behavior of the map during navigation. To set the camera mode, set the cameraMode property of the map view, specifying one of the following camera mode constants:

To change the camera mode, set the cameraMode property of the map view, as shown here:

Swift
// Set the mode to "overview":
mapView.cameraMode = .overview

// Set the mode to "free":
mapView.cameraMode = .free

// Set the mode to "following":
mapView.cameraMode = .following
Objective-C
// Set the mode to "overview":
mapView.cameraMode = GMSNavigationCameraModeOverview;

// Set the mode to "free":
mapView.cameraMode = GMSNavigationCameraModeFree;

// Set the mode to "following":
mapView.cameraMode = GMSNavigationCameraModeFollowing;
Automatically recenter the map

When users move the map in Navigation mode, the camera mode for the map view changes from following mode to free mode. The camera returns to following mode when the user explicitly presses Re-center. You can automate the return to following mode by using a timer to set an interval between leaving following mode, and then automatically returning to it.

Example

The following code example checks to determine whether the map is being moved by the user while in Navigation mode. If it is, then it sets a timer to switch the camera mode to following mode, centering the map after five seconds.

Swift
class YourViewController: UIViewController {

  @IBOutlet weak var mapView: GMSMapView!
  var autoFollowTimer: Timer!

  override func viewDidLoad() {
    super.viewDidLoad()
    mapView.delegate = self
    ...
  }

  ...
}

/** Implements the GMSMapViewDelegate protocol. */
extension YourViewController: GMSMapViewDelegate {
  func mapView(_ mapView: GMSMapView, willMove gesture: Bool) {
    if mapView.navigator?.isGuidanceActive == false {return}
    if !gesture {return}

    autoFollowTimer?.invalidate()
    autoFollowTimer = Timer(
      timeInterval: TimeInterval(5.0),
      target: self,
      selector: #selector(recenterMap),
      userInfo: nil,
      repeats: false)
    RunLoop.current.add(autoFollowTimer, forMode: .default)
  }

  /** Centers the map in guidance mode. */
  @objc private func recenterMap() {
    if mapView.navigator?.isGuidanceActive == true {
       mapView.cameraMode = .following
    }

    autoFollowTimer.invalidate()
    autoFollowTimer = nil
  }
}
Objective-C
@interface YourViewController : UIViewController<GMSMapViewDelegate>
...
@end


@implementation YourViewController {
  GMSMapView *_mapView;
  NSTimer *_autoFollowTimer;
  ...
}

...

- (void)viewDidLoad {
  [super viewDidLoad];
  ...
  _mapView.delegate = self;
  ...
}

...

/** Implements the GMSMapViewDelegate protocol. */
- (void)mapView:(GMSMapView *)mapView willMove:(BOOL)gesture {
  if (!_mapView.navigator.guidanceActive) return;
  if (!gesture) return;

  [_autoFollowTimer invalidate];
  _autoFollowTimer = [NSTimer scheduledTimerWithTimeInterval:5.0
                                                      target:self
                                                    selector:@selector(recenterMap)
                                                    userInfo:nil
                                                     repeats:NO];
}

/** Centers the map in guidance mode. */
- (void)recenterMap {
  if (_mapView.navigator.guidanceActive) {
    _mapView.cameraMode = GMSNavigationCameraModeFollowing;
  }

  [_autoFollowTimer invalidate];
  _autoFollowTimer = nil;
}

@end

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-14 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["You can change the user's viewpoint of the map by setting the `cameraMode` property to `following`, `overview`, or `free`."],["`Following` mode puts the camera behind the current position, `overview` mode displays the entire route, and `free` mode allows user interaction."],["The map automatically enters `free` mode when the user pans or zooms, and a **Re-center** button is available in `overview` and `free` modes to return to `following` mode."],["You can automate the return to `following` mode after a set time interval using a timer to improve user experience."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4