Per applicare uno stile al riempimento e al tratto di un poligono di confine, utilizza una chiusura di stile che accetta un GMSPlaceFeature e restituisce un GMSFeatureStyle per definire gli attributi di stile. Poi imposta la proprietà style su una chiusura di stile, che contiene la logica di stile.
Swift
letoptions=GMSMapViewOptions()options.mapID=GMSMapID(identifier:"YOUR_MAP_ID")options.camera=GMSCameraPosition(latitude:20.773,longitude:-156.01,zoom:12)letmapView=GMSMapView(options:options)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
GMSMapViewOptions*options=[[GMSMapViewOptionsalloc]init];options.camera=[GMSCameraPositioncameraWithLatitude:20.773longitude:-156.01zoom:12];options.mapID=[GMSMapIDmapIDWithIdentifier:@"MAP_ID"];GMSMapView*mapView=[[GMSMapViewalloc]initWithOptions:options];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;};
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2026-10-16 UTC."],[],[]]