Führen Sie die folgenden Schritte aus, um datengestützte Stile für Datasets einzurichten.
API-Schlüssel anfordern und APIs aktivieren
Sie benötigen ein Cloud-Projekt mit einem Rechnungskonto und müssen sowohl das Maps SDK for Android als auch die Maps Datasets API aktiviert haben, um die datengestützten Stile für Datasets nutzen zu können. Weitere Informationen erhalten Sie unter:
Ab Version 18.0.0 des Maps SDK for Android ist ein aktualisierter Karten-Renderer verfügbar. Er umfasst viele Verbesserungen, darunter Unterstützung für das cloudbasierte Gestalten von Karteninhalten.
Im Rahmen der Veröffentlichung von Version 18.2.0 des Maps SDK for Android wurde der Standard-Renderer vom alten zum aktualisierten Karten-Renderer geändert. Daher wird beim Erstellen neuer Apps oder Überarbeiten bestehender Apps nun standardmäßig der aktualisierte Karten-Renderer verwendet.
Karten-ID erstellen
Eine entsprechende Anleitung finden Sie unter Karten-ID erstellen. Legen Sie den Kartentyp auf Android fest.
Dazu ist die soeben erstellte Karten-ID erforderlich. Sie finden sie auf der Seite Kartenverwaltung.
Wie Sie die Karten-ID in den Initialisierungscode einfügen, können Sie unter Karten-ID zur App hinzufügen nachlesen.
Karten-Capabilities prüfen (erforderlich)
Datengestützte Stile für Datensätze erfordern eine Karten-ID. Wenn die Karten-ID fehlt oder eine ungültige Karten-ID übergeben wird, kann der datengestützte Stil für Datasets nicht geladen werden. Als Fehlerbehebungsschritt können Sie MapCapabilities verwenden, um zu prüfen, ob datengestützte Stile für Datasets unterstützt werden.
Kotlin
valcapabilities:MapCapabilities=googleMap.getMapCapabilities()System.out.println("Data-driven Styling is available: "+capabilities.isDataDrivenStylingAvailable())
Java
MapCapabilitiescapabilities=googleMap.getMapCapabilities();System.out.println("Data-driven Styling is available: "+capabilities.isDataDrivenStylingAvailable());
[null,null,["Zuletzt aktualisiert: 2025-08-31 (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)"]]