Ce document explique comment utiliser JSON pour créer, modifier et exporter des styles de carte. Pour savoir ce que vous pouvez styliser à l'aide de JSON, consultez la référence JSON pour le style de carte dans le cloud.
Importer un style de carte JSON
Pour créer un style de carte à l'aide de JSON, procédez comme suit :
Dans la console Google Cloud, accédez à Styles de carte et sélectionnez un projet si nécessaire.
Dans Styles de carte, cliquez sur Créer un style.
Dans la boîte de dialogue, sélectionnez l'onglet JSON.
Il existe deux façons d'importer votre style JSON :
Collez votre code de style JSON valide dans le champ, ou
science Cliquez sur Importer un fichier JSON et choisissez un fichier JSON local à utiliser. Le code de style JSON s'affiche dans le champ.
Vérifiez si votre fichier JSON contient des erreurs.
Si votre fichier JSON contient des erreurs, l'avertissement "Votre fichier JSON contient N erreurs" s'affiche. Vous pouvez le développer pour en savoir plus.
Si votre JSON est valide, l'aperçu de la carte affiche votre style personnalisé et le bouton bleu Personnaliser est disponible.
Cliquez sur Personnaliser pour créer un style de carte.
Dans votre nouveau style de carte, sélectionnez des éléments cartographiques, puis vérifiez ou modifiez leur style si nécessaire. Les éléments cartographiques dont le style est personnalisé sont indiqués par un point bleu.
Cliquez sur Enregistrer.
Dans la boîte de dialogue Enregistrer et publier le style de carte, saisissez le nom de votre style et une description (facultative), puis cliquez sur Enregistrer.
Le style est publié automatiquement et la page principale de votre nouveau style s'affiche.
Vous pouvez modifier les styles de carte à l'aide de l'onglet "JSON" de l'éditeur de style.
Les modifications apportées dans l'éditeur JSON sont répercutées dans le panneau de style. De plus, si vous apportez des modifications dans le panneau de style, vous pouvez les retrouver dans l'éditeur JSON. Les deux méthodes permettent également de mettre à jour l'aperçu de la carte.
Pour modifier un style de carte à l'aide de JSON, procédez comme suit :
Dans la console Google Cloud, accédez à Styles de carte et sélectionnez un projet si nécessaire.
Dans Styles de carte, sélectionnez un style existant dans la liste des styles.
Sur la page principale du style, sélectionnez Personnaliser.
Sélectionnez l'onglet JSON pour ouvrir l'éditeur de style JSON.
Apportez les modifications souhaitées dans l'éditeur. Vous pouvez également importer un fichier JSON.
Cliquez sur Commit (Valider) pour mettre à jour l'aperçu de la carte.
Une fois toutes les modifications effectuées, cliquez sur Enregistrer. Si vous créez un style, les modifications sont appliquées automatiquement. Si vous modifiez un style existant, les modifications sont enregistrées en tant que brouillon. Vous devez cliquer sur Publier pour appliquer vos modifications à tous les ID de carte qui utilisent ce style de carte.
Exporter un style de carte au format JSON
Pour exporter un style de carte au format JSON, procédez comme suit :
Dans la console Google Cloud, accédez à Styles de carte et sélectionnez un projet si nécessaire.
Dans Styles de carte, sélectionnez un style existant dans la liste des styles.
Sur la page principale du style, sélectionnez Personnaliser.
Sélectionnez l'onglet JSON pour ouvrir l'éditeur de style JSON.
Sélectionnez Exporter.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/27 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/08/27 (UTC)."],[],[],null,["# Use JSON with cloud-based maps styling\n\nSelect platform: [Android](/maps/documentation/android-sdk/cloud-customization/json \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/cloud-customization/json \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/cloud-customization/json \"View this page for the JavaScript platform docs.\") [Web Service](/maps/documentation/maps-static/cloud-customization/json \"View this page for the Web Service platform docs.\")\n\n\u003cbr /\u003e\n\n| **Experimental:** Features marked with the science science icon are experimental.\n\nThis document explains how to use JSON to create, edit, and export map styles.\nFor information on what you can style using JSON, see the\n[JSON reference for cloud-based maps styling](/maps/documentation/android-sdk/cloud-customization/json-reference).\n\nImport a JSON map style\n-----------------------\n\nTo create a map style using JSON, perform the following steps:\n\n1. In the Google Cloud console,\n go to [**Map styles**](https://console.cloud.google.com/google/maps-apis/studio/styles), and select a project, if needed.\n\n2. In **Map styles** , click **Create style**.\n\n3. In the dialog, select the **JSON** tab.\n\n4. There are two ways to import your JSON style:\n\n - Paste your valid JSON styling code into the field, or\n - scienceClick **Upload JSON File** and choose a local JSON file to use. The JSON styling code appears in the field.\n\n | **Note:** When importing legacy JSON, a warning appears and the style is converted to the latest JSON format. The conversion is approximate but sets you up for a richer and more customizable experience. To only use legacy JSON, see [Use embedded JSON style declarations](../styling).\n5. Check whether your JSON has errors.\n\n - If your JSON has errors, the warning \"Your JSON contains N errors\" appears and you can expand the warning to learn more.\n - If your JSON is valid, the map preview shows your custom style and the blue **Customize** button is available.\n6. Click **Customize** to create a new map style.\n\n7. In your new map style, select map features and review or change their style\n as needed. Map features with custom styles have a solid blue dot next to\n them.\n\n | **Note:** Not all styles appear at all zoom levels.\n8. Click **Save**.\n\n9. In the **Save and publish map style** box, enter a name for your style and\n optionally a description, and click **Save**.\n\nThe style is automatically published, and you see your new style's\nmain page.\n\nTo add your map style to a map ID, see\n[Associate your style to a map ID](/maps/documentation/android-sdk/cloud-customization/map-styles#associate-style-with-map-id).\n\nEdit a map style with JSON\n--------------------------\n\n| **Experimental:** This feature is experimental.\n\nYou can edit map styles using the JSON tab in the style editor.\n\nChanges made in the JSON editor are reflected in the style panel. Additionally,\nif you make changes in the style panel, you can find those changes in the JSON\neditor. Both methods also update the map preview.\n\nTo edit a map style using JSON, see the following steps:\n\n1. In the Google Cloud console,\n go to [**Map styles**](https://console.cloud.google.com/google/maps-apis/studio/styles), and select a project, if needed.\n\n2. In **Map styles**, select an existing style from the style list.\n\n3. In the style's main page, select **Customize**.\n\n4. Select the **JSON** tab to open the JSON style editor.\n\n5. Make your changes in the editor. You can also upload a JSON file.\n\n6. Click **Commit** to update the map preview.\n\n7. Once you're done with all of your changes, click **Save** . If you're\n creating a new style, the changes go live automatically. If you're making\n changes to an existing style, the changes save as a draft and you must click\n **Publish** to have your changes go live for any map IDs using that map\n style.\n\nExport a map style as JSON\n--------------------------\n\n| **Experimental:** This feature is experimental.\n\nTo export a map style as a JSON file, see the following steps:\n\n1. In the Google Cloud console,\n go to [**Map styles**](https://console.cloud.google.com/google/maps-apis/studio/styles), and select a project, if needed.\n\n2. In **Map styles**, select an existing style from the style list.\n\n3. In the style's main page, select **Customize**.\n\n4. Select the **JSON** tab to open the JSON style editor.\n\n5. Select **Export**."]]