如要使用資料集資料導向樣式,需要有地圖 ID。如果地圖 ID 缺少或傳遞無效的地圖 ID,就無法載入資料集資料導向樣式。您可以使用 MapCapabilities 進行疑難排解,確認資料集是否支援資料導向樣式。
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,["上次更新時間:2025-01-14 (世界標準時間)。"],[[["To 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."],["Ensure 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."],["You'll need to create a map ID associated with a new map style, then update your map initialization code to include this map ID."],["Before applying data-driven styling, it's crucial to check for map capabilities at runtime using `MapCapabilities` and provide fallback options for unsupported devices."],["Data-driven styling requires a valid map ID; if missing or invalid, the styling will fail to load."]]],[]]