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.
Feedback geben
Ereignisse auf Feature-Ebene
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Plattform auswählen :
Android
iOS
JavaScript
Dieses Beispiel zeigt Kartengrenzen für
GMSFeatureTypeLocality
implementiert und die
delegate -Funktion, mit der das angeklickte Element formatiert wird
Polygon dargestellt werden. Als Ergebnis wird ein Benachrichtigungsfenster mit den Ereignisdaten angezeigt.
Wichtig :Unsichtbare Elemente lösen keine Click-Events aus. Polygone müssen Folgendes aufweisen:
einen minimalen Alphawert haben, damit sie antippbar sind.
Swift
class SampleViewController : UIViewController {
private lazy var mapView : GMSMapView = GMSMapView ( frame : . zero , mapID : GMSMapID ( identifier : "YOUR_MAP_ID" ), camera : GMSCameraPosition ( latitude : 40 , longitude : - 80 , zoom : 12 ))
override func loadView () {
view = mapView
let style = FeatureStyle ( fill : . orange . withAlphaComponent ( 0.5 ), stroke : . orange , strokeWidth : 2 )
mapView . featureLayer ( of : . locality ) . style = { _ in style }
mapView . delegate = self
}
}
extension SampleViewController : GMSMapViewDelegate {
func mapView ( _ mapView : GMSMapView , didTap features : [Feature ], in featureLayer : FeatureLayer<Feature> , atLocation : CLLocationCoordinate2D ) {
let toast = UIAlertController ( title : "Clicked places" , message : ( features . compactMap { ( $ 0 as ? PlaceFeature ) ? . placeID }) . joined ( separator : ", " ), preferredStyle : . alert )
present ( toast , animated : true , completion : nil )
}
}
Objective-C
@interface SampleViewController : UIViewController <GMSMapViewDelegate >
@end
@implementation SampleViewController
- ( void ) loadView {
GMSMapView * mapView = [ GMSMapView mapWithFrame : CGRectZero mapID : [ GMSMapID mapIDWithIdentifier : @"YOUR_MAP_ID" ] camera : [ GMSCameraPosition cameraWithLatitude : 40 longitude : -80 zoom : 12 ]];
mapView . delegete = self ;
GMSFeatureStyle * style = [ GMSFeatureStyle styleWithFillColor : [[ UIColor orangeColor ] colorWithAlphaComponent : 0.5 ] strokeColor : [ UIColor orangeColor ] strokeWidth : 2.0 ];
[ mapView featureLayerOfFeatureType : GMSFeatureTypeLocality ]. style = ^ ( GMSPlaceFeature * feature ) { return style ; };
self . view = mapView ;
}
- ( void ) mapView: ( GMSMapView * ) mapView didTapFeatures: ( NSArray<id<GMSFeature> > * ) features inFeatureLayer: ( GMSFeatureLayer * ) featureLayer atLocation: ( CLLocationCoordinate2D ) location {
NSMutableArray<NSString *> * places = [ NSMutableArray array ];
for ( id<GMSFeature> feature in features ) {
if ( ! [ feature isKindOfClass : [ GMSPlaceFeature class ]]) { continue ; }
NSString * placeID = (( GMSPlaceFeature * ) feature ). placeID ;
[ places addObject : placeID ];
}
UIAlertController * toast = [ UIAlertController alertControllerWithTitle : @"Clicked places" message : [ places componentsJoinedByString : @", " ] preferredStyle : UIAlertControllerStyleAlert ];
[ self presentViewController : toast animated : YES completion : nil ];
}
Feedback geben
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers . Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2024-08-21 (UTC).
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Benötigte Informationen nicht gefunden"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Zu umständlich/zu viele Schritte"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Nicht mehr aktuell"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"Problem mit der Übersetzung"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Problem mit Beispielen/Code"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Sonstiges"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Leicht verständlich"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Mein Problem wurde gelöst"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Sonstiges"
}]
Haben Sie Feedback für uns?
{"lastModified": "Zuletzt aktualisiert: 2024-08-21\u00a0(UTC)."}
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2024-08-21 (UTC)."]]