Konfigurowanie mapy
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Wybierz platformę:
Android
iOS
Aby skonfigurować mapę pod kątem podróży na urządzeniu z iOS, wykonaj te czynności:
Inicjowanie widoku mapy
Obsługa zdarzeń na mapie
Uwaga: po zainicjowaniu widoku mapy możesz dostosowywać
mapy. Więcej informacji znajdziesz w sekcji Określanie stylu mapy .
Krok 1. Inicjowanie widoku mapy
Aby śledzić podróż, musisz zainicjować widok mapy.
Przykład poniżej pokazuje, jak zainicjować GMTCMapView
.
Swift
/*
* MapViewController.swift
*/
class ViewController : UIViewController , GMTCMapViewDelegate {
private var rideSharingMap : GMTCMapView ?
override func viewDidLoad () {
super . viewDidLoad ()
self . rideSharingMap = GMTCMapView ( frame : UIScreen . main . bounds )
self . rideSharingMap . delegate = self
self . rideSharingMap ?. settings . myLocationButton = true
self . view . addSubview ( self . rideSharingMap !)
...
}
}
Objective-C
/*
* MapViewController.h
*/
@interface MapViewController : UIViewController<GMTCMapViewDelegate>
...
@end
/*
* MapViewController.m
*/
@implementation MapViewController
- ( void ) viewDidLoad {
[ super viewDidLoad ];
...
self . mapView = [[ GMTCMapView alloc ] initWithFrame : CGRectZero ];
self . mapView . settings . myLocationButton = YES ;
self . mapView . delegate = self ;
...
}
...
@end
Krok 2. Obsługa zdarzeń wyświetlania mapy
Po zainicjowaniu widoku mapy możesz wdrożyć
przedstawiciela
do obsługi zmian zdarzeń widoku mapy w miarę przejazdu pojazdu.
Swift
func mapViewDidInitialize ( _ mapview : GMTCMapView ) {
// Handle the update to the state of the map view to browsing.
}
func mapView ( _ mapView : GMSMapView , didTapConsumerMarker mapMarker : 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 * ) mapView
didTapConsumerMarker :( nonnull GMSMarker * ) mapMarker
markerType :( GMTCMapViewMarkerType ) markerType {
// Handle the mapView marker was tapped.
}
Co dalej?
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0 , a fragmenty kodu są dostępne na licencji Apache 2.0 . Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers . Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2024-09-12 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Brak potrzebnych mi informacji"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Zbyt skomplikowane / zbyt wiele czynności do wykonania"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Nieaktualne treści"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"Problem z tłumaczeniem"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Problem z przykładami/kodem"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Inne"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Łatwo zrozumieć"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Rozwiązało to mój problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Inne"
}]
{"lastModified": "Ostatnia aktualizacja: 2024-09-12 UTC."}
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2024-09-12 UTC."]]