iOS-এ কোনো ভ্রমণ অনুসরণ করার জন্য মানচিত্র সেট আপ করতে, নিম্নলিখিত ধাপগুলি সম্পূর্ণ করুন:
ধাপ ১: মানচিত্র দৃশ্যটি শুরু করুন
ভ্রমণ অনুসরণ করতে হলে, আপনাকে মানচিত্রটি খুলতে হবে।
নিম্নলিখিত উদাহরণে দেখানো হয়েছে কিভাবে GMTCMapView ইনিশিয়ালাইজ করতে হয়।
সুইফট
/*
* 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!)
...
}
}
উদ্দেশ্য-সি
/*
* 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
ধাপ ২: ম্যাপ ভিউ ইভেন্টগুলো পরিচালনা করুন
এখন যেহেতু আপনি ম্যাপ ভিউটি ইনিশিয়ালাইজ করেছেন, যানবাহনটি তার যাত্রাপথে অগ্রসর হওয়ার সাথে সাথে ম্যাপ ভিউ ইভেন্টের পরিবর্তনগুলো পরিচালনা করার জন্য কীভাবে একটি ডেলিগেট ইমপ্লিমেন্ট করবেন তা এখানে দেওয়া হলো।
সুইফট
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.
}
উদ্দেশ্য-সি
/*
* 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.
}