<br />

Select platform: [Android](https://developers.google.com/maps/documentation/android-sdk/map.md.txt "View this page for the Android platform docs.") [iOS](https://developers.google.com/maps/documentation/ios-sdk/map.md.txt "View this page for the iOS platform docs.") [JavaScript](https://developers.google.com/maps/documentation/javascript/maptypes.md.txt "View this page for the JavaScript platform docs.")

<br />

> [!NOTE]
> **Note:** This document describes how to add a Google Map to an iOS application. If you would like to know how to launch the Google Maps standalone application, refer to the [URL Scheme](https://developers.google.com/maps/documentation/ios-sdk/urlscheme.md.txt) documentation.

Maps are represented in the API by the [`GMSMapView`](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Classes/GMSMapView.md.txt) class, a
subclass of `UIView`. The map is the most significant object in the
Maps SDK for iOS, and provides necessary methods for adding, removing
and managing other objects such as markers and polylines.

## Introduction

The Maps SDK for iOS lets you to display a Google map in
your iOS application. These maps have the same appearance as the maps you see in
the [Google Maps](https://itunes.apple.com/app/id585027354)
iOS app, and the SDK exposes many of the same features.

In addition to mapping functionality, the API also supports a range of
interactions that are consistent with the iOS UI model. For example, you can set
up interactions with a map by defining responders that react to user gestures,
such as tap and double-tap.

The key class when working with a Map object is the `GMSMapView` class.
`GMSMapView` handles the following operations automatically:

- Connecting to the Google Maps service.
- Downloading map tiles.
- Displaying tiles on the device screen.
- Displaying various controls such as pan and zoom.
- Responding to pan and zoom gestures by moving the map and zooming in or out.
  - Responding to two finger gestures by tilting the viewing angle of the map.

In addition to these automatic operations, you can control the behavior and
appearance of the map through the properties and methods exposed by the
`GMSMapView` class. Use `GMSMapView` to add and remove markers, ground
overlays and polylines, change the type of map that is displayed, and control
what is shown on the map through the [`GMSCameraPosition`](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Classes/GMSCameraPosition.md.txt)
class.

## Build Maps with SwiftUI

SwiftUI offers an additional way to create UI using a declarative approach. You
tell SwiftUI how you want your view to look along with all the different states
for it, and the system does the rest. SwiftUI handles updating the view whenever
the underlying state changes due to an event or user action.

Maps SDK for iOS is built on top of `UIKit` and doesn't provide a
SwiftUI-compatible view. Adding maps in SwiftUI requires conforming to either
`UIViewRepresentable` or `UIViewControllerRepresentable`. To learn more, see the
Codelab [adding a map to your iOS app with
SwiftUI](https://developers.google.com/codelabs/maps-platform/maps-platform-ios-swiftui#0).

## Add a map

The basic steps for adding a map are:

1. To get the SDK, obtain an API key, and add the required frameworks, follow
   the steps in:

   1. [Set Up in the Google Cloud console](https://developers.google.com/maps/documentation/ios-sdk/cloud-setup)

   2. [Use an API key](https://developers.google.com/maps/documentation/ios-sdk/get-api-key.md.txt)

   3. [Set up an Xcode Project](https://developers.google.com/maps/documentation/ios-sdk/config.md.txt)

   4. In your `AppDelegate`, provide your API key to the `provideAPIKey:`
      class method on `GMSServices`.

   5. Create or update a `ViewController`. If the map is displayed when this
      view controller becomes visible, be sure to create it within the
      `viewDidLoad` method.

   6. When initializing your map view, set configuration options with
      `GMSMapViewOptions`. Properties include the `frame`, `camera`,
      `mapID`,`backgroundColor` or `screen`.

   7. Set your [map options](https://developers.google.com/maps/documentation/ios-sdk/configure-map.md.txt#map_options) `camera` property with a
      `GMSCameraPosition` object. This specifies the center and zoom level of
      the map.

   8. Create and instantiate a `GMSMapView` class using the `GMSMapView`
      `options:` method. If this map is to be used as the view controller's
      only view, the map option `frame` default value of `CGRectZero` can be
      used as the view `frame` --- the map is resized automatically.

   9. Set the `GMSMapView` object as the view controller's view. For example,
      `self.view = mapView;`.

The below example adds a map, centered at downtown Singapore, to an app.

### Swift

```swift
import GoogleMaps

class MapObjects : UIViewController {
  override func viewDidLoad() {
    super.viewDidLoad()

    let options = GMSMapViewOptions()
    options.camera = GMSCameraPosition(latitude: 1.285, longitude: 103.848, zoom: 12)
    options.frame = self.view.bounds;

    let mapView = GMSMapView(options:options)
    self.view = mapView
  }
}
```

### Objective-C

```objective-c
- (void)viewDidLoad {
  [super viewDidLoad];

  GMSMapViewOptions *options = [[GMSMapViewOptions alloc] init];
  options.camera = [GMSCameraPosition cameraWithLatitude:1.285
                                                        longitude:103.848
                                                             zoom:12];
  options.frame = self.view.bounds;

  GMSMapView *mapView = [[GMSMapView alloc] initWithOptions:options];
  self.view = mapView;
}
```

Once you've followed these steps, you may further configure the `GMSMapView`
object.

## What's next

After you complete these steps, you can [configure the map
settings](https://developers.google.com/maps/documentation/ios-sdk/configure-map).