ضبط تنبيهات عدّاد السرعة

عند تفعيل التنقّل وضبط وضع التنقّل على "القيادة"، يعرض Navigation SDK لنظام التشغيل iOS عنصر تحكّم في الحدّ الأقصى للسرعة في أسفل يمين الخريطة الذي يعرض الحدّ الأقصى الحالي للسرعة. إذا تجاوز السائق الحد الأقصى للسرعة، يتم توسيع عنصر التحكّم لعرض مقياس سرعة بجانب شاشة الحد الأقصى للسرعة، ويؤدي ذلك إلى تشغيل تنبيهات عندما تصل السرعة إلى حد معيّن.

يُطلق Navigation SDK تلقائيًا تنبيهًا بسيطًا بشأن السرعة عندما يتجاوز السائق السرعة القصوى بمقدار 5 أميال في الساعة (أو 10 كيلومتر في الساعة)، ويغيّر لون عداد السرعة إلى اللون الأحمر. ويُطلق هذا النظام تنبيهًا كبيرًا بشأن السرعة عندما يتجاوز السائق السرعة القصوى بمقدار 10 ميل في الساعة (أو 20 كيلومتر في الساعة)، ويغيّر لون خلفية مقياس السرعة إلى اللون الأحمر.

يمكنك تخصيص حدّ السرعة الذي يتم عنده تشغيل التنبيهات وألوان النص والخلفية التي يعرضها مقياس السرعة. يمكنك أيضًا استخدام حزمة تطوير البرامج (SDK) لنظام التنقّل لإتاحة معلومات سرعة السائق. على سبيل المثال، يمكنك إتاحة معلومات السرعة لمشغّلي خدمات النقل المشترك لمساعدتهم في تشجيع سائقيهم على الالتزام بحدود السرعة وتحسين السلامة.

تخصيص الحدود القصوى لتنبيهات السرعة

يمكنك تخصيص الحدّ الأدنى لتنبيهات السرعة لكلّ من تنبيهات السرعة الطفيفة والكبيرة كنسبة مئوية تزيد عن الحدّ الأقصى للسرعة الحالية. يمكنك أيضًا تحديد مدة تجاوز الحدّ الأقصى قبل أن تعرِض الخريطة التنبيه.

يضبط مثال الرمز البرمجي التالي الحدّ الأدنى لتنبيه السرعة البسيط على خمسة بالمئة فوق الحدّ الأقصى للسرعة، والحدّ الأدنى لتنبيه السرعة الكبير على 10 بالمئة فوق الحدّ الأقصى للسرعة. يحدّد هذا الإعداد أنّ الخريطة تعرِض تنبيهًا بعد تجاوز الحدّ الأدنى للتنبيه لمدة خمس ثوانٍ.

Swift

let minorSpeedAlertThresholdPercentage: CGFloat = 0.05 let
majorSpeedAlertThresholdPercentage: CGFloat = 0.1 let
severityUpgradeDurationSeconds: TimeInterval = 5

// Configure SpeedAlertOptions let mutableSpeedAlertOptions:
GMSNavigationMutableSpeedAlertOptions = GMSNavigationMutableSpeedAlertOptions()
 mutableSpeedAlertOptions.setSpeedAlertThresholdPercentage(minorSpeedAlertThresholdPercentage,
for: .minor)
mutableSpeedAlertOptions.setSpeedAlertThresholdPercentage(majorSpeedAlertThresholdPercentage,
for: .major) mutableSpeedAlertOptions.severityUpgradeDurationSeconds =
severityUpgradeDurationSeconds

// Set SpeedAlertOptions to Navigator. mapView.navigator?.speedAlertOptions =
mutableSpeedAlertOptions; mapView.navigator?.add(self); // Only needed if
listening to the delegate events.

Objective-C

static const CGFloat minorSpeedAlertThresholdPercentage = 0.05; static const
CGFloat majorSpeedAlertThresholdPercentage = 0.1; static const NSTimeInterval
severityUpgradeDurationSeconds = 5;

// Configure SpeedAlertOptions GMSNavigationMutableSpeedAlertOptions
*mutableSpeedAlertOptions = [[GMSNavigationMutableSpeedAlertOptions alloc]
init]; [mutableSpeedAlertOptions setSpeedAlertThresholdPercentage:
minorSpeedAlertThresholdPercentage
forSpeedAlertSeverity:GMSNavigationSpeedAlertSeverityMinor];
[mutableSpeedAlertOptions
setSpeedAlertThresholdPercentage:majorSpeedAlertThresholdPercentage
forSpeedAlertSeverity:GMSNavigationSpeedAlertSeverityMajor];
[mutableSpeedAlertOptions
setSeverityUpgradeDurationSeconds:severityUpgradeDurationSeconds];

// Set SpeedAlertOptions to Navigator. mapView.navigator.speedAlertOptions =
mutableSpeedAlertOptions; [mapView.navigator addListener:self]; // Only needed
if listening to the delegate events.

تخصيص طريقة عرض مقياس السرعة لتنبيهات السرعة

يمكنك تخصيص ألوان شاشة مقياس السرعة لكل مستوى تنبيه.

يعرض الجدول التالي الألوان التلقائية لتنبيهات السرعة في فئة GMSNavigationSpeedometerUIOptions:

العنصراللون
MinorSpeedAlertBackgroundColorDayMode 0xffffff(white)
MinorSpeedAlertBackgroundColorNightMode 0x000000
MinorSpeedAlertTextColorDayMode 0xd93025
MinorSpeedAlertTextColorNightMode 0xd93025
MajorSpeedAlertBackgroundColorDayMode 0xd93025
MajorSpeedAlertBackgroundColorNightMode 0xd93025
MajorSpeedAlertTextColorDayMode 0xffffff(white)
MajorSpeedAlertTextColorNightMode 0xffffff(white)

يمكنك تحديد لون النص ولون الخلفية لمقياس السرعة لكل من تنبيهات السرعة المنخفضة والمرتفعة:

Swift

let mutableSpeedometerUIOptions: GMSNavigationMutableSpeedometerUIOptions =
GMSNavigationMutableSpeedometerUIOptions()
mutableSpeedometerUIOptions.setTextColor(minorSpeedAlertTextColor, for: .minor,
lightingMode: .normal)
mutableSpeedometerUIOptions.setTextColor(majorSpeedAlertTextColor, for: .major,
lightingMode: .normal)
mutableSpeedometerUIOptions.setBackgroundColor(minorSpeedAlertNightModeBackgroundColor,
for: .minor, lightingMode: .lowLight)
mutableSpeedometerUIOptions.setBackgroundColor(majorSpeedAlertDayModeBackgroundColor,
for: .major, lightingMode: .normal)

mapView.settings.speedometerUIOptions = mutableSpeedometerUIOptions

Objective-C

GMSNavigationMutableSpeedometerUIOptions *mutableSpeedometerUIOptions =
[[GMSNavigationMutableSpeedometerUIOptions alloc] init];
[mutableSpeedometerUIOptions setTextColor: minorSpeedAlertTextColor
forSpeedAlertSeverity: GMSNavigationSpeedAlertSeverityMinor lightingMode:
GMSNavigationLightingModeNormal]; [mutableSpeedometerUIOptions setTextColor:
majorSpeedAlertTextColor forSpeedAlertSeverity:
GMSNavigationSpeedAlertSeverityMajor lightingMode:
GMSNavigationLightingModeNormal]; [mutableSpeedometerUIOptions
setBackgroundColor: minorSpeedAlertNightModeBackgroundColor
forSpeedAlertSeverity: GMSNavigationSpeedAlertSeverityMinor lightingMode:
GMSNavigationLightingModeLowLight]; [mutableSpeedometerUIOptions
setBackgroundColor: majorSpeedAlertDayModeBackgroundColor forSpeedAlertSeverity:
GMSNavigationSpeedAlertSeverityMajor
lightingMode:GMSNavigationLightingModeNormal];

mapView.settings.speedometerUIOptions = mutableSpeedometerUIOptions;

تلقّي معلومات السرعة من السائقين

إذا كان تطبيقك يتطلّب مشاركة معلومات عن سرعة السائق، يمكنك أيضًا استخدام حزمة تطوير البرامج Navigation SDK لإتاحة معلومات سرعة السائق. يمكن أن يكون ذلك مفيدًا لتطبيقات مشاركة الركوب التي قد يريد فيها المشغّل مراقبة السرعة الزائدة للسائقين لتحسين السلامة.

على سبيل المثال، يشارك المثال التالي معلومات السرعة عندما تكون السرعة نسبة مئوية محدّدة أعلى من الحدّ الأقصى للسرعة:

Swift

// Listener method for sharing speed information when the speed exceeds the
speed limit by a specified percentage. #pragma mark GMSNavigatorListener func
navigator(_ navigator : GMSNavigator, didUpdateSpeedingPercentage
percentageAboveLimit : Float) { ... }

Objective-C

// Listener method listening to speeding feed. #pragma mark
GMSNavigatorListener - (void)navigator:(GMSNavigator *)navigator
didUpdateSpeedingPercentage:(float)percentageAboveLimit { ... }