数据集的数据驱动型样式需要地图 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,["最后更新时间 (UTC):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."]]],[]]