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.
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 Android Beta
Maps customization features are not yet available in the Google Play Services Maps Library. To test them, use the standalone Beta Maps SDK for Android.
For instructions on how to download the beta SDK, see Installing Maps SDK for Android v.3.1.0 BETA
Adding Map IDs to the existing MapFragment
You can add your Map ID through a
<fragment> element in
the activity’s layout file, by using the
MapView class, or
programmatically using the
For example, assume you created a Map ID that is stored as
a string value named
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="map_id">YOUR_MAP_ID</string> </resources>
For maps added through a
<fragment> element in
the activity’s layout file, all map fragments that should have
the custom style must specify the Map ID in the
<fragment xmlns:map="http://schemas.android.com/apk/res-auto" class="com.google.android.libraries.maps.SupportMapFragment" … map:mapId="@string/map_id" />
You can also use the
map:mapId attribute of the
to specify a Map ID:
<com.google.android.gms.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android" .... map:mapId="@string/map_id" />
To specify a Map ID programmatically, pass it to a
MapFragment mapFragment = MapFragment.newInstance( new GoogleMapOptions() .mapId(getResources().getString(R.string.map_id)));
val mapFragment = MapFragment.newInstance( GoogleMapOptions() .mapId(resources.getString(R.string.map_id)) )
In Android Studio, build and run your app as you normally would. Custom styles, as configured in the first step, will be applied to all maps with an ID.
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 and Publish the Map Style. If you associated a Map ID, saving and publishing will make the changes in style customizations for the associated maps public.
Updating style details
On the Map Styles page, you can select a map style to complete the following actions:
- View style details.
- Update Map IDs associated with a style.
- Save style customizations in the style editor without making the changes publicly visible.
- Publicly publish style customizations in the style editor.
- Rename, duplicate, or delete a 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.
Once your app is delivered to customers, custom styles for maps with Map IDs can be updated from Google Cloud console. The new styles will be reflected in your app in a few hours.
To make sure new custom styles show up immediately for testing purposes, clear app data from your test device. For more information on clearing data from your device, see Android Help - Free Up Space.
Note that settings can vary by phone. For more information, contact your device manufacturer.