Étape 2: Gérer les événements de vue cartographique
Maintenant que vous avez initialisé la vue cartographique, voici comment implémenter un délégué pour gérer les modifications d'événements de la vue cartographique à mesure que le véhicule avance.
Swift
funcmapViewDidInitialize(_mapview:GMTCMapView){// Handle the update to the state of the map view to browsing.}funcmapView(_mapView:GMSMapView,didTapConsumerMarkermapMarker:GMSMarker,markerType:GMTCMapViewMarkerType)->Bool{// Handle the mapView marker was tapped.}
Objective-C
/* * MapViewController.m */#pragma mark - GMTCMapViewDelegate implementation// Handle state update of map view.-(void)mapViewDidInitializeCustomerState:(GMTCMapView*)mapview{// Handle the update to the state of the map view to browsing.}-(void)mapView:(GMSMapView*)mapViewdidTapConsumerMarker:(nonnullGMSMarker*)mapMarkermarkerType:(GMTCMapViewMarkerType)markerType{// Handle the mapView marker was tapped.}
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/04/26 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/04/26 (UTC)."],[[["This documentation outlines how to set up and use the Google Maps SDK for iOS to track and display trips in real-time within your application."],["The guide covers initializing the map view, enabling user location, and handling events like the map becoming ready and marker taps."],["You can customize the appearance of the map using styling options provided by the SDK, as well as follow a vehicle's trip progression with built-in features."]]],["This content details how to set up a map to follow a trip in iOS. The process involves two key steps: first, initializing the map view (`GMTCMapView`) within a view controller, as demonstrated in Swift and Objective-C code examples. Second, implementing a delegate to handle map view events, which includes managing state updates and responding to marker taps. Customization of the map's style and the process to follow a trip are suggested as next steps.\n"]]