Stay organized with collections Save and categorize content based on your preferences.
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 documentation.Maps are represented in the API by the GMSMapView
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.
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 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:
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
class.
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.
The basic steps for adding a map are:
To get the SDK, obtain an API key, and add the required frameworks, follow the steps in:
In your AppDelegate
, provide your API key to the provideAPIKey:
class method on GMSServices
.
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.
When initializing your map view, set configuration options with GMSMapViewOptions
. Properties include the frame
, camera
, mapID
,backgroundColor
or screen
.
Set your map options camera
property with a GMSCameraPosition
object. This specifies the center and zoom level of the map.
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.
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.
Swiftimport 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
- (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.
After you complete these steps, you can configure the map settings.
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-07-23 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-07-23 UTC."],[[["The Maps SDK for iOS allows you to integrate Google Maps into your iOS application, offering features and interactions similar to the Google Maps app."],["`GMSMapView` is the primary class for working with maps, handling tasks like connecting to Google Maps, downloading tiles, and responding to user gestures."],["To add a map, obtain an API key, configure the `GMSMapView` object with desired settings like camera position and frame, and then set it as the view controller's view."],["SwiftUI integration requires using `UIViewRepresentable` or `UIViewControllerRepresentable` due to the SDK being built on `UIKit`."],["After adding the map, you can further configure its settings to customize its appearance and behavior."]]],[]]
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