You can use the Map Management API to programmatically manage your
cloud-based maps styling resources using the v2 (General Availability)
endpoint, as well as the v2beta (Preview) and v2alpha (Experimental)
endpoints for pre-GA features.
Summary of operations
To visualize a custom map with the Map Management API, follow these key steps:
- Create a StyleConfig: Define your map's visual appearance using a JSON representation of colors, visibility, and density settings.
- Create a MapConfig: Establish a unique Map ID that acts as the container for your map's identity and high-level features.
- Associate them with a MapContextConfig: Link your
StyleConfig(and optional datasets) to specific map variants (likeROADMAPorSATELLITE) within yourMapConfig.
Default behaviors and requirements
When using the v2 endpoints, keep the following default behaviors and requirements in mind:
- Map Type: The default map rendering type is
RASTER. To use vector-based maps, you must explicitly set themap_typetoVECTORin yourMapConfig. - Map Variant: You must specify at least one variant in
map_variantswhen creating aMapContextConfig. Omittingmap_variantsfails withINVALID_ARGUMENT, and you can't mix light and dark variants in the sameMapContextConfig. - Base Styling: If a
json_style_sheetis empty or not provided in aStyleConfig, the default unstyled Google Base map will be used.
Working with StyleConfigs
A StyleConfig contains the JSON-based styling definitions.
Create a StyleConfig
curl -X POST \
-H "X-Goog-User-Project: YOUR_PROJECT_ID" \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json" \
https://mapmanagement.googleapis.com/v2/projects/YOUR_PROJECT_ID/styleConfigs \
-d '{
"display_name": "My Custom Style",
"json_style_sheet": "{\"variant\":\"light\",\"monochrome\":true}"
}'List StyleConfigs
curl -X GET \ -H "X-Goog-User-Project: YOUR_PROJECT_ID" \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ https://mapmanagement.googleapis.com/v2/projects/YOUR_PROJECT_ID/styleConfigs
Working with MapConfigs
A MapConfig defines the identity and core rendering type of a map.
Create a MapConfig
curl -X POST \
-H "X-Goog-User-Project: YOUR_PROJECT_ID" \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json" \
https://mapmanagement.googleapis.com/v2/projects/YOUR_PROJECT_ID/mapConfigs \
-d '{
"display_name": "My New Map",
"map_type": "VECTOR"
}'Working with MapContextConfigs
A MapContextConfig links styling to a MapConfig.
Create a MapContextConfig
Use your numeric project number in the URL and resource names.
curl -X POST \
-H "X-Goog-User-Project: YOUR_PROJECT_NUMBER" \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json" \
https://mapmanagement.googleapis.com/v2/projects/YOUR_PROJECT_NUMBER/mapConfigs/YOUR_MAP_ID/mapContextConfigs \
-d '{
"map_config": "projects/YOUR_PROJECT_NUMBER/mapConfigs/YOUR_MAP_ID",
"style_config": "projects/YOUR_PROJECT_NUMBER/styleConfigs/YOUR_STYLE_ID",
"map_variants": ["ROADMAP", "NAVIGATION"]
}'Errors
- PERMISSION_DENIED: The request lacks sufficient IAM permissions or the project does not have the API enabled.
- NOT_FOUND: The specified resource (Project, MapConfig, or StyleConfig) does not exist.
- INVALID_ARGUMENT: The request body is malformed or contains invalid field values.