지도 설정

플랫폼 선택: Android iOS

iOS에서 여행을 따르도록 지도를 설정하려면 다음 단계를 완료하세요.

  1. 지도뷰 초기화
  2. 지도 이벤트 처리
를 통해 개인정보처리방침을 정의할 수 있습니다.

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.
}

다음 단계