[ Web Proxy ]
URL:
Viewing: https://developers.google.com/maps/documentation/javascript/dds-datasets/start [Back]  [Original]

Get started  |  Maps JavaScript API  |  Google for Developers Skip to main content
Send feedback

Get started Stay organized with collections Save and categorize content based on your preferences.

outlined_flag
Select platform: Android iOS JavaScript

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 the Maps JavaScript API and the Maps Datasets API enabled. To learn more, see Set 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 new map ID, follow the steps in Cloud customization. Set the Map type to JavaScript, and select the Vector option.

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

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

Create Vector map ID [Create Vector map ID]

Create a new map style

To create a new map style, follow the instructions in Create and use map styles to create the style, and associate the style with the map ID you just created.

Update your map initialization code

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

<script>
  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)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 the version to use (weekly, beta, alpha, etc.).
    // Add other bootstrap 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 a troubleshooting step, you can add a mapcapabilities_changed listener to subscribe to map capability changes. This will indicate whether the following conditions have been met:

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

// Optional: subscribe to map capability changes.
map.addListener('mapcapabilities_changed', () => {
  const mapCapabilities = map.getMapCapabilities();

  if (!mapCapabilities.isDataDrivenStylingAvailable) {
    // Data-driven styling is *not* available, add a fallback.
    // Existing feature layers are also unavailable.
  }
});

Next steps

Send feedback

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 2026-08-25 UTC.

Need to tell us more? [[["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 2026-08-25 UTC."],[],["To utilize data-driven styling, first get an API key and enable the Maps JavaScript and Datasets APIs. Create a map ID of type \"JavaScript\" and \"Vector,\" then associate it with a new map style. In the map initialization code, use the `mapId` property with your created ID and load the Maps JavaScript API with an inline bootstrap loader. Optionally, use a `mapcapabilities_changed` listener to ensure a valid map ID is used and troubleshoot any issues.\n"]]

Web Proxy Viewer  |  New URL  |  Original Page