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:
A 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.
Create a new map style
To create a new map style, follow the instructions in Create and use 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.
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]];
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
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\u003eTo utilize data-driven styling for datasets within the Maps SDK for iOS, you must set up a Google Cloud project, enable necessary APIs (Maps SDK for iOS & Maps Datasets API), and acquire an API key.\u003c/p\u003e\n"],["\u003cp\u003eA unique map ID linked to a specific map style with enabled feature layers is crucial for loading datasets and using data-driven styling.\u003c/p\u003e\n"],["\u003cp\u003eBefore implementing data-driven styling features, ensure the map's capabilities are compatible by verifying through \u003ccode\u003emapView.mapCapabilities\u003c/code\u003e or subscribing to \u003ccode\u003eGMSViewDelegate\u003c/code\u003e to detect changes and handle potential fallbacks.\u003c/p\u003e\n"],["\u003cp\u003eInitialization of the map view requires using the designated map ID containing the desired style and feature layers for data-driven styling to function correctly.\u003c/p\u003e\n"],["\u003cp\u003eYou cannot utilize a demo map ID for data-driven styling as it necessitates a map ID specifically associated with a map style containing the dataset.\u003c/p\u003e\n"]]],[],null,["Select platform: [Android](/maps/documentation/android-sdk/dds-datasets/start \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/dds-datasets/start \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/dds-datasets/start \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nFollow these steps to get set up with the data-driven styling for datasets.\n\nGet an API key and enable APIs\n\nBefore using data-driven styling for datasets, you need:\nCloud project with a billing account, and both the\nMaps SDK for iOS and the Maps Datasets API\nenabled. To learn more, see:\n\n- [Set up your Google Cloud project](/maps/documentation/ios-sdk/cloud-setup)\n\n- [Enable Maps SDK for iOS and get an API key](/maps/documentation/ios-sdk/get-api-key)\n\n- [Enable the Maps Datasets API](https://console.cloud.google.com/apis/library/mapsplatformdatasets.googleapis.com)\n\nCreate a map ID\n\nA [map ID](/maps/documentation/get-map-id) is a unique identifier that\nrepresents a Google Map specification. You can create map IDs and update\na style associated 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 [Create and use 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\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:** 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.\n\nCheck map capabilities\n\nData-driven styling for datasets 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\n[`GMSMapView`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSMapView)\nto verify whether a certain capability (for example data-driven styling) is\navailable 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).\nThis example shows how to use the protocol to check for data-driven styling\nrequirements. \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```\n\nNext steps\n\n- [Create and manage a dataset](/maps/documentation/ios-sdk/dds-datasets/create-dataset)"]]