Auf der Google Maps Platform ist bald eine neue Version der Funktionen für das cloudbasierte Gestalten von Karteninhalten verfügbar. Die Aktualisierung umfasst eine neue Standardfarbvorlage und Optimierungen in Bezug auf die Nutzerfreundlichkeit der Karten. Alle Kartenstile werden im März 2025 automatisch aktualisiert. Weitere Informationen zur Verfügbarkeit und Aktivierung sind unter Neuer Kartenstil für die Google Maps Platform verfügbar.
Um Füllung und Strich eines Begrenzungspolygons zu gestalten, verwenden Sie einen Stilabschluss, der
akzeptiert einen GMSPlaceFeature und gibt einen
GMSFeatureStyle zum Definieren von Stilattributen. Legen Sie dann
style an einen Stilabschluss, der die Stillogik enthält.
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;
};