बॉर्डर के पॉलीगॉन को स्टाइल करें

प्लैटफ़ॉर्म चुनें: iOS JavaScript

किसी सीमा वाले पॉलीगॉन के लिए फ़िल और स्ट्रोक को स्टाइल करने के लिए, ऐसे स्टाइलिंग क्लोज़र का इस्तेमाल करें जो GMSPlaceFeature को स्वीकार करता हो और स्टाइल एट्रिब्यूट तय करने के लिए GMSFeatureStyle दिखाता हो. इसके बाद, स्टाइल प्रॉपर्टी को ऐसे स्टाइल पर सेट करें जिसमें स्टाइलिंग लॉजिक हो.

बाउंड्री पॉलीगॉन फ़ीचर दिखाने वाला डायग्राम

Swift

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 }

Objective-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;
};