মার্কার কাস্টমাইজ করুন

প্ল্যাটফর্ম নির্বাচন করুন: অ্যান্ড্রয়েড আইওএস জাভাস্ক্রিপ্ট

মার্কার (অথবা পলিলাইন) কাস্টমাইজ করার আগে, আপনাকে প্রথমে UI কাস্টমাইজেশন বিকল্পগুলি শুরু করতে হবে।

UI কাস্টমাইজেশন বিকল্পগুলি শুরু করুন

প্রাথমিকভাবে UI কাস্টমাইজেশন বিকল্পগুলি সেট করার জন্য ব্যবহৃত প্রস্তাবিত কলব্যাকটি GMTCMapViewDelegate এ ঘোষণা করা হয়। GMTCMapView অবজেক্ট যখন মানচিত্র রেন্ডার করার জন্য প্রস্তুত থাকে তখন mapViewDidInitialize কলব্যাকটি ট্রিগার হয়। স্টাইল কোঅর্ডিনেটরটি শুরু করা হয়েছে, কিন্তু কোনও UI উপাদান উপস্থিত নেই।

সুইফট

/** ViewController.swift */

class ViewController: UIViewController, GMTCMapViewDelegate {

  // MARK: - GMTCMapViewDelegate

  func mapViewDidInitialize(_ mapview: GMTCMapView) {
    // Set the UI customization options here.
  }
}

অবজেক্টিভ-সি

/** ViewController.m */

@interface ViewController () <GMTCMapViewDelegate>

#pragma mark GMTCMapViewDelegate

- (void)mapViewDidInitialize:(GMTCMapView *)mapview {
  // Set the UI customization options here.
}

মার্কার কাস্টমাইজ করুন

নিচের উদাহরণে মার্কার স্টাইল কাস্টমাইজ করার জন্য GMTCMapView ব্যবহার করা হয়েছে। মার্কার টাইপ এবং এর বৈশিষ্ট্য সেট করতে, setMarkerStyleOptions(_:markerType:) ব্যবহার করুন। আপনার কাস্টম মার্কার অপশনগুলি Consumer SDK দ্বারা প্রদত্ত ডিফল্ট মানগুলিকে ওভাররাইড করে।

সুইফট

/** MapViewController.swift */

func updateMarkerUIOptions() {
  let customizableMarkerType = GMTCCustomizableMarkerType.tripVehicle
  let markerStyleOptions = GMTCMutableMarkerStyleOptions()
  markerStyleOptions.groundAnchor = groundAnchor
  markerStyleOptions.isVisible = true
  markerStyleOptions.icon = icon
  markerStyleOptions.zIndex = 100
  markerStyleOptions.isFlat = false
  let coordinator = self.mapView.consumerMapStyleCoordinator
  coordinator.setMarkerStyleOptions(markerStyleOptions, markerType: customizableMarkerType)
}

/** To restore the default values, call setMarkerStyleOptions(_:markerType:) using nil for the GMTCMarkerStyleOptions parameter.
Here is an example of retrieving the active GMTCMarkerStyleOptions. */

private func retrieveMarkerStyle(markerType: GMTCCustomizableMarkerType) {
  let styleCoordinator = mapView.consumerMapStyleCoordinator

  // The 'markerStyleOptions' contains the stored style options for this marker type.
  let markerStyleOptions = styleCoordinator.markerStyleOptions(for: markerType)
}

অবজেক্টিভ-সি


/** MapViewController.m */

- (void)updateMarkerUIOptions {
  // The marker type that you would like to set custom UI options for.
  GMTCCustomizableMarkerType customizableMarkerType = GMTCCustomizableMarkerTypeTripVehicle;

  GMTCMutableMarkerStyleOptions *markerStyleOptions =
      [[GMTCMutableMarkerStyleOptions alloc] init];
  markerStyleOptions.groundAnchor = groundAnchor;
  markerStyleOptions.isVisible = YES;
  markerStyleOptions.icon = icon;
  markerStyleOptions.zIndex = 100;
  markerStyleOptions.isFlat = NO;

  [[_mapView consumerMapStyleCoordinator] setMarkerStyleOptions:markerStyleOptions markerType:customizableMarkerType];
}

/** To restore the default values, call setMarkerStyleOptions:markerStyleOptions:markerType: using nil for the GMTCMarkerStyleOptions parameter.
Here is an example of retrieving the active GMTCMarkerStyleOptions. */

- (void)retrieveMarkerStyle:(GMTCCustomizableMarkerType)markerType {
  GMTCConsumerMapStyleCoordinator *styleCoordinator = _mapView.consumerMapStyleCoordinator;

  // The 'markerStyleOptions' contains the stored style options for this marker type.
  GMTCMarkerStyleOptions *markerStyleOptions = [styleCoordinator markerStyleOptionsForType:markerType];
}

মার্কার প্রকারভেদ

আপনি নিম্নলিখিত মার্কারগুলি কাস্টমাইজ করতে পারেন:

  • GMTCCustomizableMarkerType.unknown
  • GMTCCustomizableMarkerType.tripPickupPoint
  • GMTCCustomizableMarkerType.tripDropoffPoint
  • GMTCCustomizableMarkerType.tripVehicle
  • GMTCCustomizableMarkerType.intermediateDestination

ট্রিপ শেয়ার করার সময় ওয়েপয়েন্ট কাস্টমাইজ করতে GMTCCustomizableMarkerType.tripPickupPoint , GMTCCustomizableMarkerType.intermediateDestination এবং GMTCCustomizableMarkerType.tripDropoffPoint ব্যবহার করুন।

ট্রিপ শেয়ার করার সময় গাড়ির আইকন কাস্টমাইজ করতে GMTCCustomizableMarkerType.tripVehicle ব্যবহার করুন। ট্রিপের জন্য প্রকৃত গাড়ির ধরণ অনুসারে মার্কার আইকন পরিবর্তন হয় না।

মার্কার বিকল্পগুলি

প্রতিটি মার্কারের জন্য উপলব্ধ কাস্টমাইজযোগ্য বৈশিষ্ট্যগুলি হল Google Maps MarkerOptions দ্বারা প্রদত্ত বৈশিষ্ট্যগুলির একটি উপসেট। Consumer SDK GMTCMarkerStyleOptions নিম্নলিখিত বৈশিষ্ট্যগুলি রয়েছে:

  • একটি ইনিশিয়ালাইজার ব্যবহার করে তৈরি
  • একবার তৈরি হলে অপরিবর্তনীয়।
  • ডিফল্ট মান আছে, তাই আপনাকে কেবল যেকোনো কাস্টম মান নির্দিষ্ট করতে হবে।

আপনি নিম্নলিখিত বৈশিষ্ট্যগুলি কাস্টমাইজ করতে পারেন:

  • groundAnchor
  • isVisible : একটি মার্কার বন্ধ করতে, isVisible কে false তে সেট করুন। পর্যাপ্ত ডেটা সরবরাহ করা উচিত যাতে আপনি তার জায়গায় আপনার নিজস্ব UI উপাদান ব্যবহার করতে পারেন।
  • iconView
  • icon
  • zIndex
  • isFlat

উদাহরণ

সুইফট

/** MapViewController.swift */

private func updateMarkerUIOptions() {
  // Get the GMTCConsumerMapStyleCoordinator
  let consumerMapStyleCoordinator = mapView.consumerMapStyleCoordinator

  // The marker type that you would like to set custom UI options for.
  let customizableMarkerType = GMTCCustomizableMarkerType.tripVehicle

  // Initializing marker options.
  let markerStyleOptions = GMTCMutableMarkerStyleOptions()
  markerStyleOptions.groundAnchor = kGMSMarkerDefaultGroundAnchor
  markerStyleOptions.icon = icon
  markerStyleOptions.zIndex = 100
  markerStyleOptions.isFlat = false
  markerStyleOptions.isVisible = true

  consumerMapStyleCoordinator.setMarkerStyleOptions(markerStyleOptions, markerType: customizableMarkerType)

  // Reset marker options to default values.
  consumerMapStyleCoordinator.setMarkerStyleOptions(nil, markerType: customizableMarkerType)
}

অবজেক্টিভ-সি

/** MapViewController.m */

- (void)updateMarkerUIOptions {
  // Get the GMTCConsumerMapStyleCoordinator
  GMTCConsumerMapStyleCoordinator *consumerMapStyleCoordinator = [_mapView consumerMapStyleCoordinator];

  // The marker type that you would like to set custom UI options for.
  GMTCCustomizableMarkerType customizableMarkerType = GMTCCustomizableMarkerTypeTripVehicle;

  // Initializing marker options.
  GMTCMutableMarkerStyleOptions *markerStyleOptions =
      [[GMTCMutableMarkerStyleOptions alloc] init];
  markerStyleOptions.groundAnchor = kGMSMarkerDefaultGroundAnchor;
  markerStyleOptions.icon = icon;
  markerStyleOptions.zIndex = 100;
  markerStyleOptions.isFlat = NO;
  markerStyleOptions.isVisible = YES;

  [consumerMapStyleCoordinator setMarkerStyleOptions:markerStyleOptions markerType:customizableMarkerType];

  // Reset marker options to default values.
  [consumerMapStyleCoordinator setMarkerStyleOptions:nil markerType:customizableMarkerType];
}

পিকআপ মার্কারগুলির জন্য ডায়নামিক ETA আপডেট

একটি পিকআপ মার্কার তৈরি করতে যা পর্যায়ক্রমে আপডেট হওয়া ETA গতিশীলভাবে দেখায়, GMTCCustomizableMarkerType.tripPickupPoint এর জন্য মার্কার স্টাইল বিকল্পগুলি আপডেট করুন।

উদাহরণ

সুইফট

/** MapViewController.swift */

/// Updates the ETA every minute by creating a Timer that repeats every minute.
private func schedulePickupMarkerStyleUpdates() {
  Timer.scheduledTimer(
    timeInterval: 60.0,  // Update marker ETA every minute.
    target: self,
    selector: #selector(updatePickupMarkerETA),
    userInfo: nil,
    repeats: true)
}

/// Updates the marker options for GMTCCustomizableMarkerType.tripPickupPoint for the current time.
@objc private func updatePickupMarkerETA() {
  let consumerMapStyleCoordinator = mapView.consumerMapStyleCoordinator
  let previousOptions = consumerMapStyleCoordinator.markerStyleOptions(for: .tripPickupPoint)

  // Get updated ETA icon.
  let updatedETAIcon = pickupIconForCurrentTime()

  let markerStyleOptions = GMTCMutableMarkerStyleOptions()
  markerStyleOptions.groundAnchor = kGMSMarkerDefaultGroundAnchor
  markerStyleOptions.icon = updatedETAIcon
  markerStyleOptions.zIndex = 100
  markerStyleOptions.isFlat = false
  markerStyleOptions.isVisible = true

  consumerMapStyleCoordinator.setMarkerStyleOptions(markerStyleOptions, markerType: .tripPickupPoint)
}

অবজেক্টিভ-সি

/** MapViewController.m */

/** Updates the ETA every minute by creating an NSTimer that repeats every minute. */
- (void)schedulePickupMarkerStyleUpdates {
  [NSTimer scheduledTimerWithTimeInterval:60.0 // Update marker ETA every minute.
                                   target:self
                                 selector:@selector(updatePickupMarkerETA)
                                 userInfo:nil
                                  repeats:YES];
}

/** Updates the marker options for GMTCCustomizableMarkerTypeTripPickupPoint for the current time. */
- (void)updatePickupMarkerETA {
  GMTCConsumerMapStyleCoordinator *consumerMapStyleCoordinator = [_mapView consumerMapStyleCoordinator];
  GMTCMarkerStyleOptions *previousOptions = [consumerMapStyleCoordinator markerStyleOptionsForType:GMTCCustomizableMarkerTypeTripPickupPoint];

  // Get updated ETA icon.
  UIImage *updatedETAIcon = [self pickupIconForCurrentTime];

  GMTCMutableMarkerStyleOptions *markerStyleOptions =
                               [[GMTCMutableMarkerStyleOptions alloc] init];
  markerStyleOptions.groundAnchor = kGMSMarkerDefaultGroundAnchor;
  markerStyleOptions.icon = updatedETAIcon;
  markerStyleOptions.zIndex = 100;
  markerStyleOptions.isFlat = NO;
  markerStyleOptions.isVisible = YES;

  [consumerMapStyleCoordinator setMarkerStyleOptions:markerStyleOptions markerType:GMTCCustomizableMarkerTypeTripPickupPoint];
}

এরপর কি?