iOS에서 여행을 추적하도록 지도를 설정하려면 다음 단계를 완료하세요.
1단계: 지도 뷰 초기화
이동을 팔로우하려면 지도 뷰를 초기화해야 합니다.
다음 예는 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
2단계: 지도 뷰 이벤트 처리
이제 지도 뷰를 초기화했으므로 차량이 이동하는 동안 지도 뷰 이벤트 변경사항을 처리하는 대리자를 구현하는 방법을 알아보겠습니다.
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.
}