Bir sınır poligonunun dolgusunu ve konturunu şekillendirmek için GMSPlaceFeature kabul eden ve stil özelliklerini tanımlamak için GMSFeatureStyle döndüren bir stil kapatma kullanın. Ardından, stil özelliğini stil mantığı içeren bir stil kapatmasına ayarlayın.
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;};
[null,null,["Son güncelleme tarihi: 2025-08-31 UTC."],[[["\u003cp\u003eThis documentation explains how to style the fill and stroke of boundary polygons using a styling closure that takes a \u003ccode\u003eGMSPlaceFeature\u003c/code\u003e and returns a \u003ccode\u003eGMSFeatureStyle\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe styling closure defines the style attributes for the polygon, such as fill color, stroke color, and stroke width.\u003c/p\u003e\n"],["\u003cp\u003eStyling Places data might require integrating the Places SDK for iOS, although it's not always mandatory.\u003c/p\u003e\n"],["\u003cp\u003eCode examples in Swift and Objective-C demonstrate how to apply a purple style to a specific boundary polygon using its place ID.\u003c/p\u003e\n"]]],[],null,["Select platform: [Android](/maps/documentation/android-sdk/dds-boundaries/style-polygon \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/dds-boundaries/style-polygon \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/dds-boundaries/style-polygon \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nTo style the fill and stroke for a boundary polygon, use a styling closure that\naccepts a [`GMSPlaceFeature`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSPlaceFeature) and returns a\n[`GMSFeatureStyle`](/maps/documentation/ios-sdk/reference/objc/Classes/GMSFeatureStyle) to define style attributes. Then set the\nstyle property to a styling closure, which contains styling logic.\n\n**Important:** While not required for all capabilities, styling of Places data may require integration with the [Places SDK for iOS](/maps/documentation/places/ios-sdk). \n\nSwift \n\n```swift\nlet mapView = GMSMapView(frame: .zero, mapID: GMSMapID(identifier: \"YOUR_MAP_ID\"), camera: GMSCameraPosition(latitude: 20.773, longitude: -156.01, zoom: 12))\n\nlet layer = mapView.featureLayer(of: .locality)\n\n// Define a style with purple\nlet style = FeatureStyle(fill: .purple.withAlphaComponent(0.5), stroke: .purple, strokeWidth: 3.0)\n\n// Apply the style to a single boundary.\nlayer.style = { ($0.placeID == \"ChIJ0zQtYiWsVHkRk8lRoB1RNPo\"/* Hana, HI */) ? style : nil }\n```\n\nObjective-C \n\n```objective-c\nGMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero mapID:[GMSMapID mapIDWithIdentifier:@\"MAP_ID\"] camera:[GMSCameraPosition cameraWithLatitude: 20.773 longitude: -156.01 zoom:12]];\n\nGMSFeatureLayer\u003cGMSPlaceFeature *\u003e *layer = [mapView featureLayerOfFeatureType:GMSFeatureTypeLocality];\n\n// Define a style with purple fill and border.\nGMSFeatureStyle *style = [GMSFeatureStyle styleWithFillColor:[[UIColor purpleColor] colorWithAlphaComponent:0.5] strokeColor:[UIColor purpleColor] strokeWidth:3.0];\n\n// Apply the style to a single boundary.\nlayer.style = ^(GMSPlaceFeature *feature) {\n return [feature.placeID isEqual:@\"ChIJ0zQtYiWsVHkRk8lRoB1RNPo\"/* Hana, HI */] ? style : nil;\n};\n```"]]