Select platform: [Android](https://developers.google.com/maps/documentation/mobility/journey-sharing/on-demand/android/create-ui.md.txt "View this page for the Android platform docs.") [iOS](https://developers.google.com/maps/documentation/mobility/journey-sharing/on-demand/ios/create-ui.md.txt "View this page for the iOS platform docs.")

<br />

To set up a map to follow a trip in iOS, complete the following steps:

1. [Initialize the map view](https://developers.google.com/maps/documentation/mobility/journey-sharing/on-demand/ios/create-ui.md.txt#map-view)
2. [Handle map events](https://developers.google.com/maps/documentation/mobility/journey-sharing/on-demand/ios/create-ui.md.txt#handle-updates)

> [!NOTE]
> **Note:** After you initialize the map view, you can customize the map. For more details, see [Style a map](https://developers.google.com/maps/documentation/mobility/journey-sharing/on-demand/ios/style.md.txt).

## Step 1: Initialize the map view

To follow a trip, you must initialize a map view.

The following example shows how to initialize `GMTCMapView`.

### Swift

```swift
/*
 * MapViewController.swift
 */
class ViewController: UIViewController, GMTCMapViewDelegate {
  private var rideSharingMap: GMTCMapView?

  override func viewDidLoad() {
    super.viewDidLoad()

    self.rideSharingMap = GMTCMapView(frame: UIScreen.main.bounds)
    self.rideSharingMap.delegate = self
    self.rideSharingMap?.settings.myLocationButton = true
    self.view.addSubview(self.rideSharingMap!)
    ...
    }
  }
```

### Objective-C

```objective-c
/*
 * MapViewController.h
 */
@interface MapViewController : UIViewController<GMTCMapViewDelegate>
...
@end

/*
 * MapViewController.m
 */
@implementation MapViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  ...
  self.mapView = [[GMTCMapView alloc] initWithFrame:CGRectZero];
  self.mapView.settings.myLocationButton = YES;
  self.mapView.delegate = self;
  ...
}

...

@end
```

## Step 2: Handle map view events

Now that you've initialized the map view, here's how to implement a delegate
to handle map view event changes as the vehicle progresses along its journey.

### Swift

```swift
func mapViewDidInitialize(_ mapview: GMTCMapView) {
  // Handle the update to the state of the map view to browsing.
}

func mapView(_ mapView: GMSMapView, didTapConsumerMarker mapMarker: GMSMarker, markerType: GMTCMapViewMarkerType) -> Bool {
  // Handle the mapView marker was tapped.
}
```

### Objective-C

```objective-c
/*
 * MapViewController.m
 */
#pragma mark - GMTCMapViewDelegate implementation

// Handle state update of map view.
- (void)mapViewDidInitializeCustomerState:(GMTCMapView *)mapview {
  // Handle the update to the state of the map view to browsing.
}

- (void)mapView:(GMSMapView *)mapView
    didTapConsumerMarker:(nonnull GMSMarker *)mapMarker
              markerType:(GMTCMapViewMarkerType)markerType {
  // Handle the mapView marker was tapped.
}
```

## What's next

- [Style a map](https://developers.google.com/maps/documentation/mobility/journey-sharing/on-demand/ios/style.md.txt)
- [Follow a trip in iOS](https://developers.google.com/maps/documentation/mobility/journey-sharing/on-demand/ios/share-journey.md.txt)