রুট সংক্রান্ত তথ্য পাওয়া

বর্তমান রুটের জন্য সময়, দূরত্ব এবং রুটের লেগ সংক্রান্ত তথ্য পেতে আপনার অ্যাপ সেট-আপ করতে এই নির্দেশিকা অনুসরণ করুন।

এক নজরে

বর্তমান রুট সম্পর্কে তথ্য পেতে, navigator ইনস্ট্যান্স থেকে উপযুক্ত প্রপার্টি পান:

  • GMSNavigator.timeToNextDestination বর্তমান রুটে পরবর্তী গন্তব্যে পৌঁছানোর আনুমানিক সময় সেকেন্ডে জানতে।
  • GMSNavigator.distanceToNextDestination বর্তমান রুটে পরবর্তী গন্তব্যের দূরত্ব মিটারে পেতে।
  • GMSNavigationDelayCategory ট্রাফিক ফ্লোয়ের জন্য বিলম্বের বিভাগ পেতে।
  • GMSNavigator.currentRouteLeg বর্তমান রুটের লেগ সম্পর্কে তথ্য পেতে।
  • GMSNavigator.traveledPath সবচেয়ে সম্প্রতি ভ্রমণ করা পথ পেতে।

কোড দেখুন

পরবর্তী গন্তব্যে পৌঁছাতে কত সময় লাগবে তা দেখা হচ্ছে

পরের গন্তব্যে পৌঁছাতে কত সময় লাগবে তা জানতে, timeToNextDestination() নম্বরে কল করুন। এটি একটি NSTimeInterval মান রিটার্ন করে। নিচের উদাহরণে দেখানো হয়েছে যে পরবর্তী গন্তব্যে পৌঁছানোর সময় কীভাবে লগ করতে হয়:

Swift

if let navigator = mapView.navigator {
  let time = navigator.timeToNextDestination
  let minutes = floor(time/60)
  let seconds = round(time - minutes * 60)
  NSLog("Time to next destination: %.0f:%.0f", minutes, seconds)
}

Objective-C

NSTimeInterval time = _mapView.navigator.timeToNextDestination;
int minutes = floor(time/60);
int seconds = round(time - minutes * 60);
NSLog(@"%@", [NSString stringWithFormat:@"Time to next destination: %i:%i.", minutes, seconds]);

পরবর্তী গন্তব্যের দূরত্ব জানা

পরবর্তী গন্তব্যের দূরত্ব জানতে, distanceToNextDestination() নম্বরে কল করুন। এটি CLLocationDistance ভ্যালু রিটার্ন করে। ইউনিট মিটারে উল্লেখ করা হয়েছে।

Swift

if let navigator = mapView.navigator {
  let distance = navigator.distanceToNextDestination
  let miles = distance * 0.00062137
  NSLog("Distance to next destination: %.2f miles.", miles)
}

Objective-C

CLLocationDistance distance = _mapView.navigator.distanceToNextDestination;
double miles = distance * 0.00062137;
NSLog(@"%@", [NSString stringWithFormat:@"Distance to next destination: %.2f.", miles]);

পরবর্তী গন্তব্যের ট্রাফিক পরিস্থিতি সংগ্রহ করা হচ্ছে

পরবর্তী গন্তব্যে ট্রাফিকের ফ্লো নির্দেশ করে এমন একটি ভ্যালু পেতে, delayCategoryToNextDestination কল করুন। এই প্যারামিটার GMSNavigationDelayCategory রিটার্ন করে। নিচের উদাহরণে ফলাফল মূল্যায়ন করা এবং ট্রাফিক মেসেজ লগ করা দেখানো হয়েছে:

Swift

if let navigator = mapView.navigator {
  // insert sample for evaluating traffic value
  let delay = navigator.delayCategoryToNextDestination
  let traffic = "unavailable"
  switch delay {
    case .noData:
      traffic = "unavailable"
    case .heavy:
      traffic = "heavy"
    case .medium:
      traffic = "moderate"
    case .light:
      traffic = "light"
    default:
      traffic = "unavailable"
  }
  print("Traffic is \(traffic).")
}

Objective-C

GMSNavigationDelayCategory delay = mapView.navigator.delayCategoryToNextDestination;
NSString *traffic = @"";

switch (delayCategory) {
    case GMSNavigationDelayCategoryNoData:
      traffic = @"No Data";
      break;
    case GMSNavigationDelayCategoryHeavy:
      traffic = @"Heavy";
      break;
    case GMSNavigationDelayCategoryMedium:
      traffic = @"Medium";
      break;
    case GMSNavigationDelayCategoryLight:
      traffic = @"Light";
      break;
    default:
      NSLog(@"Invalid delay category: %zd", delayCategory);
 }

NSLog(@"%@", [NSString stringWithFormat:@"Traffic is %@.", traffic]);

ভ্রমণের বর্তমান পর্যায় সম্পর্কে তথ্য পাওয়া

বর্তমান রুটের লেগ সম্পর্কে তথ্য পেতে, currentRouteLeg নম্বরে কল করুন। এটি একটি GMSRouteLeg ইনস্ট্যান্স রিটার্ন করে, যেখান থেকে আপনি এগুলি পেতে পারেন:

  • এই লেগের গন্তব্য।
  • লেগের শেষ কোঅর্ডিনেট।
  • সেই পাথ যাতে রুট লেগ তৈরি করা কোঅর্ডিনেট থাকে।

নিম্নলিখিত উদাহরণে পরবর্তী রুটের লেগের জন্য শিরোনাম এবং অক্ষাংশ/দ্রাঘিমাংশ কোঅর্ডিনেট লগ করা দেখানো হয়েছে:

Swift

if let navigator = mapView.navigator {
  let currentLeg = navigator.currentRouteLeg
  let nextDestination = currentLeg?.destinationWaypoint?.title
  let lat = currentLeg?.destinationCoordinate.latitude.description
  let lng = currentLeg?.destinationCoordinate.longitude.description
  NSLog(nextDestination! + ", " + lat! + "/" + lng!)
}

Objective-C

GMSRouteLeg *currentSegment = _mapView.navigator.currentRouteLeg;
NSString *nextDestination = currentSegment.destinationWaypoint.title;
CLLocationDegrees lat = currentSegment.destinationCoordinate.latitude;
CLLocationDegrees lng = currentSegment.destinationCoordinate.longitude;
NSLog(@"%@", [NSString stringWithFormat:@"%@, %f/%f", nextDestination, lat, lng]);

সবচেয়ে সম্প্রতি ভ্রমণ করা পথ পাওয়া যাচ্ছে

সবচেয়ে সম্প্রতি ট্রাভেল করা পাথ পেতে, কল করুন traveledPath. এটি একটি GMSPath ইনস্ট্যান্স রিটার্ন করে যা অপ্রয়োজনীয় পয়েন্ট (যেমন পরপর কোলিনিয়ার পয়েন্টকে একটি লাইন সেগমেন্টে পরিবর্তন করা) সরানোর জন্য সরলীকৃত করা হয়েছে। নির্দেশনা শুরু না হওয়া পর্যন্ত এই পাথ খালি থাকে। নিম্নলিখিত উদাহরণে দেখানো হয়েছে যে কীভাবে সবচেয়ে সম্প্রতি ভ্রমণ করা পথের তথ্য পাওয়া যায়:

Swift

if let navigator = mapView.navigator {
  let latestPath = navigator.traveledPath
  if latestPath.count() > 0 {
    let begin: CLLocationCoordinate2D = latestPath.coordinate(at: 0)
    let current: CLLocationCoordinate2D = latestPath.coordinate(at: latestPath.count() - 1)
    print("Path from (\(begin.latitude),\(begin.longitude)) to (\(current.latitude),\(current.longitude))")
  }
}

Objective-C

GMSPath *latestPath = mapView.navigator.traveledPath;
if (latestPath.count > 0) {
  CLLocationCoordinate2D begin = [latestPath coordinateAtIndex:0];
  CLLocationCoordinate2D current = [latestPath coordinateAtIndex:latestPath.count - 1];
  NSLog(@"Path from %f/%f to %f/%f",
        begin.latitude,
        begin.longitude,
        current.latitude,
        current.longitude);
}