Places UI Kit: A ready-to-use library that provides room for customization and low-code development. Try it out, and share yourinput on your UI Kit experience.

Get started

  • To utilize data-driven styling for datasets, obtain an API key, enable necessary APIs (Maps JavaScript API and Maps Datasets API), and create a map ID associated with a vector-based map style.

  • Initialization involves providing the map ID during map instantiation and loading the Maps JavaScript API with thev=beta parameter in the script tag.

  • For troubleshooting, optionally use themapcapabilities_changed listener to verify map capabilities, such as a valid map ID linked to a vector map, ensuring data-driven styling functionality.

  • After setup, proceed to create and upload a dataset to leverage data-driven styling within your maps.

Select platform:AndroidiOSJavaScript

Follow these steps to get set up with the data-driven styling for datasets.

Get an API key and enable APIs

Before using the data-driven styling for datasets, you need:Google Cloud project with a billing account, and both theMaps JavaScript API and the Maps Datasets API enabled.To learn more, seeSet up your Google Cloud project.

Get an API key

Enable the Maps JavaScript API

Enable the Maps Datasets API

Create a map ID

To create a newmap ID,follow the steps inCloud customization.Set the Map type toJavaScript, and select theVector option.

Provide a map ID using themapId property when you instantiate the map .The map ID must correspond to the map style that is associated with the datasetto display.

constposition=newgoogle.maps.LatLng(40.75,-74.05);constmap=newgoogle.maps.Map(document.getElementById('map'),{zoom:11,center:position,mapId:'YOUR_MAP_ID',});

Create Vector map ID

Create a new map style

To create a new map style, follow the instructions inCreate and use map stylesto create the style, andassociate the style with the map ID you just created.

Update your map initialization code

To use the data-driven styling for datasets, first load theMaps JavaScript API, by adding the inline bootstrap loader toyour application code, as shown here(usev=beta in your APIscript tag):

<script>(g=>{varh,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});vard=b.maps||(b.maps={}),r=newSet,e=newURLSearchParams,u=()=>h||(h=newPromise(async(f,n)=>{await(a=m.createElement("script"));e.set("libraries",[...r]+"");for(king)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({key:"YOUR_API_KEY",v:"weekly",// Use the 'v' parameter to indicate theversion to use (weekly, beta, alpha, etc.).// Add otherbootstrap parameters as needed, using camel case.});</script>

Check map capabilities (optional)

Data-driven styling for datasets requires a map ID. If the map ID is missing,or an invalid map ID is passed, data features cannot load. As atroubleshooting step, you can add amapcapabilities_changed listener tosubscribe to map capability changes. This will indicate whether the followingconditions have been met:

  • A valid map ID is in use.
  • The map ID is associated with a vector map.

Using Map Capabilities is optional, and recommended only for testing andtroubleshooting purposes, or for runtime fallback purposes.

// Optional: subscribe to map capability changes.map.addListener('mapcapabilities_changed',()=>{constmapCapabilities=map.getMapCapabilities();if(!mapCapabilities.isDataDrivenStylingAvailable){// Data-driven styling is *not* available, add a fallback.// Existing feature layers are also unavailable.}});

Next steps

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-11-21 UTC.