Stay organized with collections Save and categorize content based on your preferences.
Follow these steps to get set up with data-driven styling for boundaries.
Enable the new maps rendererAn upgraded map renderer is available as of version 18.0.0 of the Maps SDK for Android. This renderer brings many improvements, including support for Cloud-based maps styling, to Maps SDK for Android.
With the release of version 18.2.0 of the Maps SDK for Android, Google switched the default renderer from the legacy renderer to the upgraded map renderer. This change means that the upgraded map renderer is now used by default in your app when you build a new app or rebuild an existing app.
Caution: To use data-driven styling for boundaries in your app, your app must be built using the upgraded map renderer. If you are adding data-driven styling for boundaries to an existing app, ensure that you rebuild the app so that your app uses the upgraded map renderer. For more information, see New Map Renderer. Create a map IDTo create a new map ID, follow the steps at Create a map ID. Make sure you set the Map type to Android.
Create a new map styleTo create a new map style, follow the instructions in Manage map styles to create the style, and associate the style with the map ID you just created.
Experimental: This feature can only be set for light map styles. When you link a light map style that has this feature enabled to a map ID, the enabled layers are also available for the dark map style. Select the feature layers in your new map styleIn the Google API Console you can select which feature layers to display for your new map style. The feature layer determines which kinds of boundaries appear on the map (for example localities, states, and so on).
Important: For optimal performance, only select the layers you need.This step requires the map ID you just created. It can be found on your Maps Management page.
To add the map ID to your initialization code, see Add the map ID to your app.
Get access to a feature layer of a mapYou use a FeatureLayer
object to represent each feature layer of a map, such as a Postal Code or Locality feature layer. To get access to a feature layer object, call GoogleMap.getFeatureLayer()
when the map initializes:
private FeatureLayer postalCodeLayer;Kotlin
@Override public void onMapReady(GoogleMap map) { // Get the POSTAL_CODE feature layer. postalCodeLayer = map.getFeatureLayer(new FeatureLayerOptions.Builder() .featureType(FeatureType.POSTAL_CODE) .build()); ... }
private var postalCodeLayer: FeatureLayer? = null
override fun onMapReady(googleMap: GoogleMap) { // Get the POSTAL_CODE feature layer. postalCodeLayer = googleMap.getFeatureLayer(new FeatureLayerOptions.Builder() .featureType(FeatureType.POSTAL_CODE) .build()) ... }
Pass a FeatureLayerOptions
object to getFeatureLayer()
to specify the type of the feature layer. In this example, you want to access the POSTAL_CODE
layer. Create a different FeatureLayer
object for each layer that you want to style.
Once you have the FeatureLayer
object, you can apply styling to the boundary polygons in that feature.
FeatureLayer
of the specified type does not exist for the map, or if data-driven styling for boundaries is not enabled because you have not specified the map ID, this call returns but logs an error. Use the FeatureLayer.isAvailable()
method to determine if a FeatureLayer
is available. Check map capabilities (required)
Data-driven styling for boundaries requires a map ID. If the map ID is missing, or an invalid map ID is passed, data-driven styling for boundaries cannot load. As a troubleshooting step, you can use MapCapabilities
to check if data-driven styling for boundaries is supported.
MapCapabilities
to check for support at runtime. If data-driven styling for boundaries is not supported, define a fallback option. For device requirements for the new map renderer, see Supported devices. Kotlin
val capabilities: MapCapabilities = googleMap.getMapCapabilities() System.out.println("Data-driven Styling is available: " + capabilities.isDataDrivenStylingAvailable())Java
MapCapabilities capabilities = googleMap.getMapCapabilities(); System.out.println("Data-driven Styling is available: " + capabilities.isDataDrivenStylingAvailable());
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["Data-driven styling for boundaries requires using the upgraded map renderer (available since Maps SDK for Android v18.0.0) and creating a map ID with an associated map style."],["You can select specific boundary feature layers (like Postal Code or Locality) to display on your map by customizing your map style in the Google Cloud Console, optimizing for performance by choosing only necessary layers."],["To apply data-driven styling, get access to feature layers via `GoogleMap.getFeatureLayer()` with `FeatureLayerOptions` defining the desired layer type, and style them individually."],["Before implementing data-driven styling, it's crucial to check for device compatibility using `MapCapabilities.isDataDrivenStylingAvailable()` at runtime and provide a fallback in case it's not supported."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4