The following instructions show how to use the Google Cloud console to create, customize, publish, and manage your maps at any time using Map IDs and Map Styles.
To create or manage any Map IDs or Map Styles in your Google Cloud project, you must have the Project Owner or Project Editor IAM role.
Before you begin
- Use Xcode Version 11 or later.
- Use the Maps Beta framework or Maps Beta CocoaPod.
- Have a working
UIViewControllerset to show a
Creating Map IDs
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 Google Cloud Console without changing embedded JSON styling in your application code.
To create a Map ID:
In the Cloud Console, go to the Maps Management page.
Click Create New Map ID, to display the Create New Map ID form.
In the form, do the following:
- Specify a map name.
- Specify a map type or platform.
- Enter a description of the map.
- Click Next to display the new Map ID.
Installing Maps SDK for iOS Beta
Maps customization features are currently available in the Maps SDK for iOS BETA, which can be installed using Cocoapods or Carthage.
For instructions on how to download the beta SDK, see Maps SDK for iOS v.3.10.0 BETA
Using Map IDs in your application code
To instantiate a map using a Map ID, do the folowing:
- Create a
GMSMapIDwith the Map ID string from Google Cloud Console.
- Create a
GMSMapViewspecifying the Map ID you just created.
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
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 on Google 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.
Creating Map Styles
A Map Style is a unique identifier for a set of customizations that can be associated with any Map ID.
To create a new style:
In the Cloud Console, go to the Map Styles page.
Click Create New Map Style to open the Create New Style page.
In the Create New Style page, you can do the following:
Select a Map Style from one of the available templates, or import existing JSON styling code by pasting your JSON code into the text box on the Import JSON tab.
Apply styling to a map by selecting map names. A single map style can be applied to multiple maps. You can always change the Map Style associated with a Map ID later.
Customize the display of different map features by clicking the Customize in Style Editor button. In the Style Editor, you can:
- Change the styling of features on a map, such as roads, bodies of water, and commercial corridors.
- Filter points of interest to specific business types.
- Specify the display of points of interest density.
Create a name and description to Save or Publish the Map Style. If you associate a Map ID with your Map Style, saving and publishing will make the style changes public for the associated maps. Saving style customizations without publishing in the style editor will not make the changes publicly visible.
Updating style details
On the Map Styles page, you can select a map style to complete the following actions:
- Continue customizing or view style details in the style editor by clicking the Customize style button.
- Rename or edit a description for the style by clicking the Edit button.
- Duplicate the style by clicking the Duplicate button.
- Delete the style by clicking the Delete button.
- View Map IDs associated with the style.
Styles created before September 15, 2020 will not display Google Maps enhanced natural features. To use Google Maps enhanced natural features support for your map styling, you must create a Map Style.
Customizing at different zoom levels
You can customize the style of existing elements at different zoom levels when creating map styles with the style editor in Google Cloud Console.
For example, you can customize the color of water from pink at zoom level 0 to purple at zoom level 10, and associate other customizations with the level of detail you see at the specified zoom. To try out this feature in a sample app, run the GoogleMap sample app and view the CloudBasedMapStylingViewController project (GitHub sample for Swift | Objective-C).
To make style customizations at different zoom levels:
- Open the style editor in Cloud Console. To do this, visit the Map Styles page, and either create a Map Style or update an existing Map Style.
- Select a feature in the Feature type submenu to open up the Element type submenu, and select an element you would like to customize.
Check the Customize across zooms checkbox to make customizations at the current zoom level appear in the style editor.
Once you select the Customize across zooms checkbox, you should see the following:
- An Add stop: z checkbox that indicates your current zoom level and attaches customizations to the indicated zoom level.
- A zoom slider bar to modify and select your zoom level. You can adjust zoom levels with map boolean zoom controls, mousewheel, or arrow keys on your keyboard.
When you make customizations in the Stylers submenu, the style editor automatically selects the Add stop: z checkbox, displays a blue dot above the slider, and overrides any inherited styles.
The blue dot above your slider indicates that changes were made at the selected zoom level. To prevent changes from being saved at a particular zoom level, clear the Add stop: z checkbox (the blue dot turns gray to indicate that changes will not be saved at that level). After clearing the checkbox, the element returns to its inherited style.
Any customizations you make at a zoom level will update the customizations at the indicated zoom levels and above. For example, customizations at zoom level 10 affect all customizations at zoom levels 10, 11, 12 and so on. The customizations override any inherited styles.
To save your changes, click Save. To make your changes public on the map IDs associated with your map style, click Publish.
Optional Cloud Styling CocoaPod or GitHub demo
Instead of starting from scratch, you can try out our Maps customization demo, which is installed by following the instructions in the Using the Google Maps Beta CocoaPod section.
Alternatively, you can find an Objective-C sample application that demonstrates how to style your iOS map from the cloud here.
Building the Beta demo app
In Xcode, press the compile button to build and then run the current scheme.
The build produces an error, prompting you to enter your API key in the
If you don't yet have an API key, follow the instructions
to set up a project on the Google Cloud Console and get an API key. When
configuring the key on the Google Cloud Console, you can specify your app's
bundle identifier to ensure that only your app can use the key. The default
bundle identifier of the SDK samples app is
SDKDemoAPIKey.h file and paste your API key into the definition
of the kAPIKey constant:
static NSString *const kAPIKey = @"YOUR_API_KEY";
If Xcode prompts you to unlock the SDKDemoAPIKey.h file for editing, choose Unlock.
Remove the following line:
#error Register for API Key and insert here.
Build and run the project.
Maps customization Map Demo
CloudStyling demo shows how to style the map by using a style set on Google Cloud Console.
When the demo application launches, click on the Map Customization demo in the Beta Samples section at the top of the list.
Click on Style Map to see the effect of loading different Map IDs.
You can try adding your own style as well ("Style Map" > "Add a new Map ID"), and see the map update with your custom styled map.