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

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

আপনি মার্কার (বা পলিলাইন) কাস্টমাইজ করার আগে, আপনাকে প্রথমে 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:) ব্যবহার করুন। আপনার কাস্টম মার্কার বিকল্পগুলি উপভোক্তা 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 দ্বারা প্রদত্ত বৈশিষ্ট্যগুলির একটি উপসেট৷ কনজিউমার SDK GMTCMarkerStyleOptions এর নিম্নলিখিত বৈশিষ্ট্য রয়েছে:

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

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

  • groundAnchor
  • isVisible : একটি মার্কার বন্ধ করতে, isVisible তে মিথ্যা সেট করুন। আপনার নিজের 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];
}

এরপর কি