It's the 15th anniversary of Google Maps Platform - Check out the latest news and announcements


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.


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:


import UIKit
import GoogleMaps

class DemoViewController: UIViewController, GMSMapViewDelegate {


@import UIKit;
@import GoogleMaps;

@interface DemoViewController : UIViewController<GMSMapViewDelegate>

When the GMSMapView is created, you can set its delegate to your view controller. The GMSMapViewDelegate provides only optional methods. To listen to any particular event, you must implement the relevant method.


override func loadView() {
  let camera = 1.285,
                                        longitude: 103.848,
                                        zoom: 12)

  let mapView = .zero, camera: camera)
  mapView.delegate = self
  self.view = mapView

// MARK: GMSMapViewDelegate

func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D) {
  print("You tapped at \(coordinate.latitude), \(coordinate.longitude)")


- (void)loadView {
  GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:1.285
  GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
  mapView.delegate = self;
  self.view = mapView;

#pragma mark - GMSMapViewDelegate

- (void)mapView:(GMSMapView *)mapView
    didTapAtCoordinate:(CLLocationCoordinate2D)coordinate {
  NSLog(@"You tapped at %f,%f", coordinate.latitude, coordinate.longitude);

Camera position

Using the GMSMapViewDelegate, you can listen to changes to the camera position used to render the map. There are three distinct events.

  • mapView:willMove: indicates that the camera position is about to change. If the gesture argument is set to YES, this is due to a user performing a natural gesture on the GMSMapView, such as a pan or tilt. Otherwise, NO indicates that this is part of a programmatic change - for example, via methods such as animateToCameraPosition: or updating the map's layer directly. This may also be NO if a user has tapped on the My Location or compass buttons, which generate animations that change the camera.

    This method may be called several times before mapView:idleAtCameraPosition: is invoked, although this typically happens only if animations and gestures occur at the same time - a gesture will cancel any current animation, for instance, and will call mapView:willMove: a second time.

  • mapView:didChangeCameraPosition: is called repeatedly during a gesture or animation, always after a call to mapView:willMove:. It is passed the intermediate camera position.

  • Finally, mapView:idleAtCameraPosition: is invoked once the camera position on GMSMapView becomes idle, and specifies the relevant camera position. At this point, all animations and gestures have stopped.

    Applications can use this event to trigger a refresh of markers or other content being displayed on the GMSMapView, rather than, for example, reloading the content on every camera change.

For example, an application can clear the GMSMapView on move, and then reverse geocode the position the camera comes to rest on.


// Store GMSGeocoder as an instance variable.
let geocoder = GMSGeocoder()


func mapView(_ mapView: GMSMapView, willMove gesture: Bool) {

func mapView(_ mapView: GMSMapView, idleAt cameraPosition: GMSCameraPosition) {
    geocoder.reverseGeocodeCoordinate( { (response, error) in
      guard error == nil else {

      if let result = response?.firstResult() {
        let marker = GMSMarker()
        marker.position =
        marker.title = result.lines?[0]
        marker.snippet = result.lines?[1] = mapView


// You must define a GMSGeocoder property in your .h file and initialize it
// in your initializer or viewDidLoad() method.

#pragma mark - GMSMapViewDelegate

- (void)mapView:(GMSMapView *)mapView willMove:(BOOL)gesture {
  [mapView clear];

- (void)mapView:(GMSMapView *)mapView
    idleAtCameraPosition:(GMSCameraPosition *)cameraPosition {
  id handler = ^(GMSReverseGeocodeResponse *response, NSError *error) {
    if (error == nil) {
      GMSReverseGeocodeResult *result = response.firstResult;
      GMSMarker *marker = [GMSMarker];
      marker.title = result.lines[0];
      marker.snippet = result.lines[1]; = mapView;
  [self.geocoder completionHandler:handler];

Events on businesses and other points of interest

By default, points of interest (POIs) appear on the base map along with their corresponding icons. POIs include parks, schools, government buildings, and more, as well as business POIs such as shops, restaurants, and hotels.

You can respond to click events on a POI. See the guide to businesses and other points of interest.

Other events

To learn about the full list of methods on GMSMapViewDelegate, see the reference guide.