Select platform: [Android](https://developers.google.com/maps/documentation/android-sdk/dds-datasets/start.md.txt "View this page for the Android platform docs.") [iOS](https://developers.google.com/maps/documentation/ios-sdk/dds-datasets/start.md.txt "View this page for the iOS platform docs.") [JavaScript](https://developers.google.com/maps/documentation/javascript/dds-datasets/start.md.txt "View this page for the JavaScript platform docs.")

<br />

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

## Get an API key and enable APIs

Before using data-driven styling for datasets, you need:
Cloud project with a billing account, and both the
Maps SDK for iOS and the Maps Datasets API
enabled. To learn more, see:

- [Set up your Google Cloud project](https://developers.google.com/maps/documentation/ios-sdk/cloud-setup)

- [Enable Maps SDK for iOS and get an API key](https://developers.google.com/maps/documentation/ios-sdk/get-api-key.md.txt)

- [Enable the Maps Datasets API](https://console.cloud.google.com/apis/library/mapsplatformdatasets.googleapis.com)

## Create a map ID

A [map ID](https://developers.google.com/maps/documentation/get-map-id) is a unique identifier that
represents a Google Map specification. You can create map IDs and update
a style associated with a map ID at any time in the Google Cloud console.

![A screenshot of Google Cloud
console](https://developers.google.com/static/maps/documentation/ios-sdk/images/ios-map-id.png)

## Create a new map style

To create a new map style, follow the instructions in [Create and use map
styles](https://developers.google.com/maps/documentation/ios-sdk/cloud-customization/map-styles) to create
the style. Once complete associate the style with the newly created map ID.

## Update your map initialization code

This step requires a map ID be associated with a style with one or more feature
layers enabled. To verify your map ID is set up correctly in
Cloud console, review how it is configured under [Maps
Management](https://console.cloud.google.com/google/maps-apis/studio/maps).

### Swift

```swift
// A map ID using a style with one or more feature layers enabled

let mapID = GMSMapID(identifier: "YOUR_MAP_ID")
let camera = GMSCameraPosition(latitude: 40, longitude: -80, zoom: 7)
let options = GMSMapViewOptions()
options.camera = camera
options.mapID = mapID
let mapView = GMSMapView(options: options)
```

### Objective-C

```objective-c
// A map ID using a style with one or more feature layers enabled

GMSMapID *mapID = [GMSMapID mapIDWithIdentifier:@"MAP_ID"];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:40 longitude:-80 zoom:7];
GMSMapViewOptions *options = [[GMSMapViewOptions alloc] init];
options.camera = camera;
options.mapID = mapID;
GMSMapView *mapView = [[GMSMapView alloc] initWithOptions:options];
```

> [!IMPORTANT]
> **Important:** You cannot use a demo map ID because a map ID with the linked map style is needed to load the dataset to the client.

## Check map capabilities

Data-driven styling for datasets requires capabilities which are enabled in the
Google Cloud console, and associated with a map ID. Because map IDs are subject to
change, you can call
[`mapView.mapCapabilities`](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Classes/GMSMapView.md.txt#mapcapabilities)
on a
[`GMSMapView`](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Classes/GMSMapView.md.txt)
to verify whether a certain capability (for example data-driven styling) is
available prior to calling it.

You can also detect changes in map capabilities by subscribing to
[`GMSViewDelegate`](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Protocols/GMSMapViewDelegate.md.txt).
This example shows how to use the protocol to check for data-driven styling
requirements.

### Swift

```swift
class SampleViewController: UIViewController {

  private lazy var mapView: GMSMapView = {
    let options = GMSMapViewOptions()
    options.mapID = GMSMapID(identifier: "YOUR_MAP_ID")
    options.camera = GMSCameraPosition(latitude: 40, longitude: -80, zoom: 7)
    return GMSMapView(options: options)
  }()

  override func loadView() {
    self.view = mapView
    mapView.delegate = self
  }
}

extension SampleViewController: GMSMapViewDelegate {
  func mapView(_ mapView: GMSMapView, didChange mapCapabilities: GMSMapCapabilityFlags) {
    if (!mapCapabilities.contains(.dataDrivenStyling)) {
      // Data-driven styling is *not* available, add a fallback.
      // Existing feature layers are also unavailable.
    }
  }
}
```

### Objective-C

```objective-c
@interface SampleViewController: UIViewController <GMSMapViewDelegate>
@end

@implementation SampleViewController
- (void)loadView {
  GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:40 longitude:-80 zoom:7];
  GMSMapViewOptions *options = [[GMSMapViewOptions alloc] init];
  options.camera = camera;
  options.mapID = [GMSMapID mapIDWithIdentifier:@"MAP_ID"];
  GMSMapView *mapView = [[GMSMapView alloc] initWithOptions:options];
  mapView.delegate = self;
  self.view = mapView;
}

- (void)mapView:(GMSMapView *)mapView didChangeMapCapabilities:(GMSMapCapabilityFlags)mapCapabilities {
  if (!(mapCapabilities & GMSMapCapabilityFlagsDataDrivenStyling)) {
    // Data-driven styling is *not* available, add a fallback.
    // Existing feature layers are also unavailable.
  }
}
@end
```

## Next steps

- [Create and manage a dataset](https://developers.google.com/maps/documentation/ios-sdk/dds-datasets/create-dataset.md.txt)