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 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.
Create a new map style
To create a new map style, follow the instructions in Manage map
styles to create
the style. Once complete associate the style with the newly created map ID.
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).
Click the Feature layers drop-down to add or remove layers.
Click Save to save your changes and make them available to your maps.
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.
Swift
// A map ID using a style with one or more feature layers enabledletmapID=GMSMapID(identifier:"YOUR_MAP_ID")letmapView=GMSMapView(frame:.zero,mapID:mapID,camera:GMSCameraPosition(latitude:40,longitude:-80,zoom:7))
Objective-C
// A map ID using a style with one or more feature layers enabledGMSMapID*mapID=[GMSMapIDmapIDWithIdentifier:@"MAP_ID"];GMSMapView*mapView=[GMSMapViewmapWithFrame:CGRectZeromapID:mapIDcamera:[GMSCameraPositioncameraWithLatitude:40longitude:-80zoom:7]];
Add feature layers to a map
To get a reference to a feature layer on your map, call
mapView.featureLayer(of:)
when the map initializes:
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
on a GMSMapView 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. This example shows how to use the
protocol to check for data-driven styling requirements.
Swift
classSampleViewController:UIViewController{privatelazyvarmapView:GMSMapView=GMSMapView(frame:.zero,mapID:GMSMapID(identifier:"YOUR_MAP_ID"),camera:GMSCameraPosition(latitude:40,longitude:-80,zoom:7))overridefuncloadView(){self.view=mapViewmapView.delegate=self}}extensionSampleViewController:GMSMapViewDelegate{funcmapView(_mapView:GMSMapView,didChangemapCapabilities:GMSMapCapabilityFlags){if(!mapCapabilities.contains(.dataDrivenStyling)){// Data-driven styling is *not* available, add a fallback.// Existing feature layers are also unavailable.}}}
Objective-C
@interfaceSampleViewController: UIViewController<GMSMapViewDelegate>
@end@implementationSampleViewController-(void)loadView{GMSMapView*mapView=[GMSMapViewmapWithFrame:CGRectZeromapID:[GMSMapIDmapIDWithIdentifier:@"MAP_ID"]camera:[GMSCameraPositioncameraWithLatitude:40longitude:-80zoom:7]];mapView.delegete=self;self.view=mapView;}-(void)mapView:(GMSMapView*)mapViewdidChangeMapCapabilities:(GMSMapCapabilityFlags)mapCapabilities{if(!(mapCapabilities&GMSMapCapabilityFlagsDataDrivenStyling)){// Data-driven styling is *not* available, add a fallback.// Existing feature layers are also unavailable.}}@end
[[["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-18 UTC."],[[["\u003cp\u003eData-driven styling for boundaries requires creating a map ID and associating it with a custom map style that includes selected feature layers.\u003c/p\u003e\n"],["\u003cp\u003eYou can manage feature layers, such as localities and states, in the Google Cloud console to control which boundaries are displayed.\u003c/p\u003e\n"],["\u003cp\u003eUpdate your map initialization code to use the map ID, ensuring data-driven styling is enabled for the map.\u003c/p\u003e\n"],["\u003cp\u003eUtilize \u003ccode\u003emapView.featureLayer(of:)\u003c/code\u003e to access specific feature layers on your map for further styling or interaction.\u003c/p\u003e\n"],["\u003cp\u003eVerify map capabilities, including data-driven styling, using \u003ccode\u003emapView.mapCapabilities\u003c/code\u003e or by subscribing to \u003ccode\u003eGMSViewDelegate\u003c/code\u003e to detect changes and implement fallbacks if needed.\u003c/p\u003e\n"]]],[],null,["Select platform: [Android](/maps/documentation/android-sdk/dds-boundaries/start \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/dds-boundaries/start \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/dds-boundaries/start \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nTo use data-driven styling for boundaries you must create a map ID. Next, you\nmust create a new map style, select the needed boundary feature layers, and\nassociate the style with your map ID.\n\nCreate a map ID\n\nA [mapID](/maps/documentation/get-map-id) is a unique identifier that represents\na single instance of a Google Map. You can create map IDs and update a style\nassociated with a map ID at any time in the Google Cloud console.\n\nCreate a new map style\n\nTo create a new map style, follow the instructions in [Manage map\nstyles](/maps/documentation/ios-sdk/cloud-customization/map-styles) to create\nthe style. Once complete associate the style with the newly created map ID.\n| **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\n| ID](../map-ids/mapid-over), the enabled layers are also available for the dark map style.\n\nSelect feature layers\n\nIn the Google Cloud console you can select which feature layers to display. This\ndetermines which kinds of boundaries appear on the map (for example localities,\nstates, and so on).\n| **Important:** For optimal performance, only select the layers you need.\n\nManage feature layers\n\n1. In the Google Cloud console, [go to the Map Styles\n page](https://console.cloud.google.com/project/_/google/maps-apis/studio/styles)\n\n2. Select a project if prompted.\n\n3. Select a map style.\n\n4. Click the **Feature layers** drop-down to add or remove layers.\n\n5. Click **Save** to save your changes and make them available to your maps.\n\nUpdate your map initialization code\n\nThis step requires a map ID be associated with a style with one or more feature\nlayers enabled. To verify your map ID is set up correctly in\nCloud console, review how it is configured under [Maps\nManagement](https://console.cloud.google.com/google/maps-apis/studio/maps). \n\nSwift \n\n```swift\n// A map ID using a style with one or more feature layers enabled\n\nlet mapID = GMSMapID(identifier: \"YOUR_MAP_ID\")\nlet mapView = GMSMapView(frame: .zero, mapID: mapID, camera: GMSCameraPosition(latitude: 40, longitude: -80, zoom: 7))\n```\n\nObjective-C \n\n```objective-c\n// A map ID using a style with one or more feature layers enabled\n\nGMSMapID *mapID = [GMSMapID mapIDWithIdentifier:@\"MAP_ID\"];\nGMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero mapID:mapID camera:[GMSCameraPosition cameraWithLatitude:40 longitude:-80 zoom:7]];\n```\n| **Important:** For testing, you can skip the step of creating and configuring a [map\n| ID](/maps/documentation/get-map-id), by using mapId: [`DEMO_MAP_ID`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSMapID) in your app code. `DEMO_MAP_ID` is intended for testing purposes only. Don't use `DEMO_MAP_ID` in a production environment.\n\nAdd feature layers to a map\n\nTo get a reference to a feature layer on your map, call\n[`mapView.featureLayer(of:)`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSMapView#-featurelayeroffeaturetype:)\nwhen the map initializes: \n\nSwift \n\n```swift\nlet layer = mapView.featureLayer(of: .locality)\n```\n\nObjective-C \n\n```objective-c\nGMSFeatureLayer *layer = [mapView featureLayerOfFeatureType:GMSFeatureTypeLocality];\n```\n\nCheck map capabilities\n\nData-driven styling for boundaries requires capabilities which are enabled in the\nGoogle Cloud console, and associated with a map ID. Because map IDs are subject to\nchange, you can call\n[`mapView.mapCapabilities`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSMapView#mapcapabilities)\non a [`GMSMapView`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSMapView) to verify whether a certain capability (for\nexample data-driven styling) is available prior to calling it.\n\nYou can also detect changes in map capabilities by subscribing to\n[`GMSViewDelegate`](/maps/documentation/ios-sdk/reference/objc/Protocols/GMSMapViewDelegate). This example shows how to use the\nprotocol to check for data-driven styling requirements. \n\nSwift \n\n```swift\nclass SampleViewController: UIViewController {\n\n private lazy var mapView: GMSMapView = GMSMapView(frame: .zero, mapID: GMSMapID(identifier: \"YOUR_MAP_ID\"), camera: GMSCameraPosition(latitude: 40, longitude: -80, zoom: 7))\n\n override func loadView() {\n self.view = mapView\n mapView.delegate = self\n }\n}\n\nextension SampleViewController: GMSMapViewDelegate {\n func mapView(_ mapView: GMSMapView, didChange mapCapabilities: GMSMapCapabilityFlags) {\n if (!mapCapabilities.contains(.dataDrivenStyling)) {\n // Data-driven styling is *not* available, add a fallback.\n // Existing feature layers are also unavailable.\n }\n }\n}\n```\n\nObjective-C \n\n```objective-c\n@interface SampleViewController: UIViewController \u003cGMSMapViewDelegate\u003e\n@end\n\n@implementation SampleViewController\n- (void)loadView {\n GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero mapID:[GMSMapID mapIDWithIdentifier:@\"MAP_ID\"] camera:[GMSCameraPosition cameraWithLatitude:40 longitude:-80 zoom:7]];\n mapView.delegete = self;\n self.view = mapView;\n}\n\n- (void)mapView:(GMSMapView *)mapView didChangeMapCapabilities:(GMSMapCapabilityFlags)mapCapabilities {\n if (!(mapCapabilities & GMSMapCapabilityFlagsDataDrivenStyling)) {\n // Data-driven styling is *not* available, add a fallback.\n // Existing feature layers are also unavailable.\n }\n}\n@end\n```"]]