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

<br />

To use data-driven styling for boundaries you must create a map ID. Next, you
must create a new map style, select the needed boundary feature layers, and
associate the style with your map ID.

## Create a map ID

A [mapID](https://developers.google.com/maps/documentation/get-map-id) is a unique identifier that represents
a single instance of a Google Map. 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 [Manage 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.

> [!WARNING]
> **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](https://developers.google.com/maps/documentation/ios-sdk/map-ids/mapid-over), the enabled layers are also available for the dark map style.

## Select feature layers

In the Google Cloud console you can select which feature layers to display. This
determines which kinds of boundaries appear on the map (for example localities,
states, and so on).

> [!IMPORTANT]
> **Important:** For optimal performance, only select the layers you need.

## Manage feature layers

1. In the Google Cloud console, [go to the Map Styles
   page](https://console.cloud.google.com/project/_/google/maps-apis/studio/styles)

2. Select a project if prompted.

3. Select a map style.

4. Click the **Feature layers** drop-down to add or remove layers.

5. Click **Save** to save your changes and make them available to your maps.

![A screenshot showing the
drop-down.](https://developers.google.com/static/maps/documentation/ios-sdk/images/feature_layer_dropdown.png)

## 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:** For testing, you can skip the step of creating and configuring a [map
> ID](https://developers.google.com/maps/documentation/get-map-id), by using mapId: [`DEMO_MAP_ID`](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Classes/GMSMapID.md.txt) in your app code. `DEMO_MAP_ID` is intended for testing purposes only. Don't use `DEMO_MAP_ID` in a production environment.

## Add feature layers to a map

To get a reference to a feature layer on your map, call
[`mapView.featureLayer(of:)`](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Classes/GMSMapView.md.txt#-featurelayeroffeaturetype:)
when the map initializes:

### Swift

```swift
let layer = mapView.featureLayer(of: .locality)
```

### Objective-C

```objective-c
GMSFeatureLayer *layer = [mapView featureLayerOfFeatureType:GMSFeatureTypeLocality];
```

## Check map capabilities

Data-driven styling for boundaries 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
```