New basemap styling is coming soon to Google Maps Platform. This update to map styling includes a new default color palette, modernized pins, and improvements to map experiences and usability. All map styles will be automatically updated in March 2025. For more information on availability and how to opt in earlier, see New map style for Google Maps Platform.
To style the fill and stroke for a boundary polygon, use a styling closure that
accepts a GMSPlaceFeature and returns a
GMSFeatureStyle to define style attributes. Then set the
style property to a styling closure, which contains styling logic.
Swift
letmapView=GMSMapView(frame:.zero,mapID:GMSMapID(identifier:"YOUR_MAP_ID"),camera:GMSCameraPosition(latitude:20.773,longitude:-156.01,zoom:12))letlayer=mapView.featureLayer(of:.locality)// Define a style with purpleletstyle=FeatureStyle(fill:.purple.withAlphaComponent(0.5),stroke:.purple,strokeWidth:3.0)// Apply the style to a single boundary.layer.style={($0.placeID=="ChIJ0zQtYiWsVHkRk8lRoB1RNPo"/* Hana, HI */)?style:nil}
Objective-C
GMSMapView*mapView=[GMSMapViewmapWithFrame:CGRectZeromapID:[GMSMapIDmapIDWithIdentifier:@"MAP_ID"]camera:[GMSCameraPositioncameraWithLatitude:20.773longitude:-156.01zoom:12]];GMSFeatureLayer<GMSPlaceFeature*>*layer=[mapViewfeatureLayerOfFeatureType:GMSFeatureTypeLocality];// Define a style with purple fill and border.GMSFeatureStyle*style=[GMSFeatureStylestyleWithFillColor:[[UIColorpurpleColor]colorWithAlphaComponent:0.5]strokeColor:[UIColorpurpleColor]strokeWidth:3.0];// Apply the style to a single boundary.layer.style=^(GMSPlaceFeature*feature){return[feature.placeIDisEqual:@"ChIJ0zQtYiWsVHkRk8lRoB1RNPo"/* Hana, HI */]?style:nil;};
[[["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 2024-11-21 UTC."],[],[]]