Выполните следующие шаги, чтобы настроить стили на основе данных для наборов данных.
Получите ключ API и включите API
Перед использованием стилизации на основе данных для наборов данных вам потребуется: облачный проект с платёжной учётной записью, а также поддержка Maps SDK для Android и API наборов данных Карт. Подробнее см.:
Обновлённый рендерер карт доступен с версии 18.0.0 Maps SDK для Android. Он вносит множество улучшений, включая поддержку облачной стилизации карт в Maps SDK для Android.
С выпуском версии 18.2.0 Maps SDK для Android компания Google изменила стандартный рендерер с устаревшего на обновлённый. Это изменение означает, что обновлённый рендерер карт теперь будет использоваться по умолчанию в вашем приложении при сборке нового приложения или пересборке существующего.
Создать идентификатор карты
Чтобы создать новый идентификатор карты, следуйте инструкциям в разделе «Создание идентификатора карты» . Убедитесь, что в качестве типа карты выбрано Android .
Для стилизации, управляемой данными, для наборов данных требуется идентификатор карты. Если идентификатор карты отсутствует или передан недействительный идентификатор карты, стилизация, управляемая данными, для наборов данных не загрузится. Для устранения неполадок можно использовать MapCapabilities , чтобы проверить, поддерживается ли стилизация, управляемая данными, для наборов данных.
Котлин
valcapabilities:MapCapabilities=googleMap.getMapCapabilities()System.out.println("Data-driven Styling is available: "+capabilities.isDataDrivenStylingAvailable())
Ява
MapCapabilitiescapabilities=googleMap.getMapCapabilities();System.out.println("Data-driven Styling is available: "+capabilities.isDataDrivenStylingAvailable());
[[["Прост для понимания","easyToUnderstand","thumb-up"],["Помог мне решить мою проблему","solvedMyProblem","thumb-up"],["Другое","otherUp","thumb-up"]],[["Отсутствует нужная мне информация","missingTheInformationINeed","thumb-down"],["Слишком сложен/слишком много шагов","tooComplicatedTooManySteps","thumb-down"],["Устарел","outOfDate","thumb-down"],["Проблема с переводом текста","translationIssue","thumb-down"],["Проблемы образцов/кода","samplesCodeIssue","thumb-down"],["Другое","otherDown","thumb-down"]],["Последнее обновление: 2025-09-04 UTC."],[[["\u003cp\u003eTo utilize data-driven styling for datasets, you'll need a Cloud project with billing enabled, the Maps SDK for Android, and the Maps Datasets API enabled.\u003c/p\u003e\n"],["\u003cp\u003eEnsure your app uses the upgraded map renderer (available since version 18.0.0 of the Maps SDK for Android) to support data-driven styling, rebuilding the app if necessary.\u003c/p\u003e\n"],["\u003cp\u003eYou'll need to create a map ID associated with a new map style, then update your map initialization code to include this map ID.\u003c/p\u003e\n"],["\u003cp\u003eBefore applying data-driven styling, it's crucial to check for map capabilities at runtime using \u003ccode\u003eMapCapabilities\u003c/code\u003e and provide fallback options for unsupported devices.\u003c/p\u003e\n"],["\u003cp\u003eData-driven styling requires a valid map ID; if missing or invalid, the styling will fail to load.\u003c/p\u003e\n"]]],[],null,["Select platform: [Android](/maps/documentation/android-sdk/dds-datasets/start \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/dds-datasets/start \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/dds-datasets/start \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nFollow these steps to get set up with data-driven styling for datasets.\n\nGet an API key and enable APIs\n\nBefore using data-driven styling for datasets, you need:\nCloud project with a billing account, and both the\nMaps SDK for Android and the Maps Datasets API\nenabled. To learn more, see:\n\n- [Set up your Google Cloud project](/maps/documentation/android-sdk/cloud-setup)\n\n- [Enable Maps SDK for Android and get an API key](/maps/documentation/android-sdk/get-api-key)\n\n- [Enable the Maps Datasets API](https://console.cloud.google.com/apis/library/mapsplatformdatasets.googleapis.com)\n\nEnable the new maps renderer\n\nAn upgraded map renderer is available as of version 18.0.0 of the\nMaps SDK for Android. This renderer brings many improvements, including\nsupport for Cloud-based maps styling, to Maps SDK for Android.\n\nWith the release of version 18.2.0 of the Maps SDK for Android, Google switched the\ndefault renderer from the legacy renderer to the upgraded map renderer. This\nchange means that the upgraded map renderer is now used by default in your app\nwhen you build a new app or rebuild an existing app.\n| **Caution:** To use data-driven styling for datasets in your app, your app must be built using the upgraded map renderer. If you are adding data-driven styling for datasets to an existing app, rebuild the app to use the upgraded map renderer. For more information, see [New Map Renderer](/maps/documentation/android-sdk/renderer).\n\nCreate a map ID\n\nTo create a new map ID, follow the steps at\n[Create a map ID](/maps/documentation/get-map-id#create-a-map-id). Be sure to\nset the Map type to **Android**.\n\nCreate a new map style\n\nTo create a new map style, follow the instructions in\n[Create and use map styles](/maps/documentation/android-sdk/cloud-customization/map-styles)\nto create the style, and\n[associate the style with the map ID you just created](/maps/documentation/android-sdk/cloud-customization/map-styles#associate-style-with-map-id).\n\nUpdate your map initialization code\n\nThis step requires the map ID you just created. It can be found on your\n[Maps Management](https://console.cloud.google.com/google/maps-apis/studio/maps) page.\n\nTo add the map ID to your initialization code, see\n[Add the map ID to your app](/maps/documentation/get-map-id#add-a-map-id-to-your-app).\n\nCheck map capabilities (required)\n\nData-driven styling for datasets requires a map ID. If the map ID is missing, or an\ninvalid map ID is passed, data-driven styling for datasets cannot load. As a\ntroubleshooting step, you can use\n[`MapCapabilities`](/android/reference/com/google/android/gms/maps/model/MapCapabilities)\nto check if data-driven styling for datasets is supported.\n| **Caution:** Some devices might not support the new map renderer and therefore cannot display data-driven styling for datasets. You must use `MapCapabilities` to check for support at runtime. If data-driven styling for datasets is not supported, define a fallback option. For device requirements for the new map renderer, see [Supported\ndevices](/maps/documentation/android-sdk/renderer#supported-devices). \n\nKotlin\n\n\n```java\nval capabilities: MapCapabilities = googleMap.getMapCapabilities()\nSystem.out.println(\"Data-driven Styling is available: \" + capabilities.isDataDrivenStylingAvailable())\n```\n\n\u003cbr /\u003e\n\nJava\n\n\n```java\nMapCapabilities capabilities = googleMap.getMapCapabilities();\nSystem.out.println(\"Data-driven Styling is available: \" + capabilities.isDataDrivenStylingAvailable());\n```\n\n\u003cbr /\u003e\n\nNext steps\n\n- [Create and manage a dataset](/maps/documentation/android-sdk/dds-datasets/create-dataset)"]]