Using Map IDs

Map IDs are identifiers you create in the Google Cloud Console, associate with a style, then put into your app code to apply that style to your map.

Upon creation, Map IDs are associated with a project, and are also restricted to a single platform (Android, iOS, JavaScript) or to the Maps Static API.

To create or manage any Map IDs in your Cloud Console, you must have the Project Owner or Project Editor IAM role.

Creating a Map ID

A Map ID is a unique identifier that represents a single instance of a Google Map. You can create Map IDs and update a style associated with a Map ID at any time in the Cloud Console.

To create a Map ID:

  1. In the Cloud Console, go to the Maps Management page.
  2. Select Create New Map ID to display the Create New Map ID form.
    Create New Map ID

    In the form, do the following:

    • Specify a map name.
    • Specify a map type or platform.
    • For JavaScript maps, choose raster or vector map type.
    • Enter a description of the map.
    • Select Next to display the new Map ID.

Associating a Map ID to a map style

These instructions assume that there is at least one existing map style in your project.

  1. In the Cloud Console, go to the Maps Management page.
  2. On this page, select an existing Map ID from the Map name column.
  3. At the bottom of this form, choose a map style from the Map styles associated with this Map ID dropdown.
  4. Select Save.
    Screenshot showing the details page for a single Map ID, including the dropdown field that lets users associate a map style with this Map ID.

Adding a Map ID to your app

To instantiate a map using a Map ID, do the folowing:

  1. Create a GMSMapID with the Map ID string from Cloud Console.
  2. Create a GMSMapView specifying the Map ID you just created.

Swift

let camera = GMSCameraPosition(latitude: 47.0169, longitude: -122.336471, zoom: 12)
let mapID = GMSMapID(identifier: "<YOUR MAP ID>")
let mapView = GMSMapView(frame: .zero, mapID: mapID, camera: camera)
self.view = mapView

Objective-C

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:47.0169
                                                        longitude:-122.336471
                                                             zoom:12];
GMSMapID *mapID = [GMSMapID mapIDWithIdentifier:@"<YOUR MAP ID>"];
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero mapID:mapID camera:camera];
self.view = mapView;

If you are using your own Map ID, you can set your Map ID in the Cloud Console to have a new style at any time, and that style will be reflected on your map view automatically for you and users within about six hours.

If you want to see the changes immediately, you can close out and restart your app by exiting the app, forcing a quit of the app from the recently-used apps list, and then reopening it. The updated map will then be visible.