This document explains how to use JSON to create, edit, and export map styles. For information on what you can style using JSON, see the JSON reference for cloud-based maps styling.
Import a JSON map style
To create a map style using JSON, perform the following steps:
In the Google Cloud console, go to Map styles, and select a project, if needed.
In Map styles, click Create style.
In the dialog, select the JSON tab.
There are two ways to import your JSON style:
- Paste your valid JSON styling code into the field, or
- Click Upload JSON File and choose a local JSON file to use. The JSON styling code appears in the field.
Check whether your JSON has errors.
- If your JSON has errors, the warning "Your JSON contains N errors" appears and you can expand the warning to learn more.
- If your JSON is valid, the map preview shows your custom style and the blue Customize button is available.
Click Customize to create a new map style.
In your new map style, select map features and review or change their style as needed. Map features with custom styles have a solid blue dot next to them.
Click Save.
In the Save and publish map style box, enter a name for your style and optionally a description, and click Save.
The style is automatically published, and you see your new style's main page.
To add your map style to a map ID, see Associate your style to a map ID.
Edit a map style with JSON
You can edit map styles using the JSON tab in the style editor.
Changes made in the JSON editor are reflected in the style panel. Additionally, if you make changes in the style panel, you can find those changes in the JSON editor. Both methods also update the map preview.
To edit a map style using JSON, see the following steps:
In the Google Cloud console, go to Map styles, and select a project, if needed.
In Map styles, select an existing style from the style list.
In the style's main page, select Customize.
Select the JSON tab to open the JSON style editor.
Make your changes in the editor. You can also upload a JSON file.
Click Commit to update the map preview.
Once you're done with all of your changes, click Save. If you're creating a new style, the changes go live automatically. If you're making changes to an existing style, the changes save as a draft and you must click Publish to have your changes go live for any map IDs using that map style.
Export a map style as JSON
To export a map style as a JSON file, see the following steps:
In the Google Cloud console, go to Map styles, and select a project, if needed.
In Map styles, select an existing style from the style list.
In the style's main page, select Customize.
Select the JSON tab to open the JSON style editor.
Select Export.