به یک چند ضلعی مرزی سبک دهید

پلتفرم را انتخاب کنید: iOS JavaScript

برای استایل پر کردن و استروک برای چند ضلعی مرزی، از یک بسته بندی استایلی استفاده کنید که یک GMSPlaceFeature را می پذیرد و یک GMSFeatureStyle را برای تعریف ویژگی های سبک برمی گرداند. سپس ویژگی style را روی یک بسته بندی استایل قرار دهید که حاوی منطق استایل است.

نموداری که ویژگی چندضلعی مرزی را نشان می دهد

سریع

let mapView = GMSMapView(frame: .zero, mapID: GMSMapID(identifier: "YOUR_MAP_ID"), camera: GMSCameraPosition(latitude: 20.773, longitude: -156.01, zoom: 12))

let layer = mapView.featureLayer(of: .locality)

// Define a style with purple
let style = 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 }

هدف-C

GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero mapID:[GMSMapID mapIDWithIdentifier:@"MAP_ID"] camera:[GMSCameraPosition cameraWithLatitude: 20.773 longitude: -156.01 zoom:12]];

GMSFeatureLayer<GMSPlaceFeature *> *layer = [mapView featureLayerOfFeatureType:GMSFeatureTypeLocality];

// Define a style with purple fill and border.
GMSFeatureStyle *style = [GMSFeatureStyle styleWithFillColor:[[UIColor purpleColor] colorWithAlphaComponent:0.5] strokeColor:[UIColor purpleColor] strokeWidth:3.0];

// Apply the style to a single boundary.
layer.style = ^(GMSPlaceFeature *feature) {
  return [feature.placeID isEqual:@"ChIJ0zQtYiWsVHkRk8lRoB1RNPo"/* Hana, HI */] ? style : nil;
};