Skip to main content

Average speed control sections

Last updated: September 14, 2026 | 3 minutes read

An average speed control section is an enforcement zone bounded by an entry gantry and an exit gantry, where the average speed between the two gantries is measured rather than the instantaneous speed. The SDK reports the driver's progress and running average inside such a zone through SpeedSectionAlarm.

For instantaneous speed limit monitoring, see Speed warnings.

Listen for section events​

The section callbacks carry no arguments and have to read the sections back from the service. Declare the service before the listener and create it afterwards, which is the pattern the SDK itself documents:

AlarmService? alarmService;

AlarmListener alarmListener = AlarmListener(
onApproachingSpeedSectionAlarms: () {
for (final section in alarmService!.approachingSpeedSectionAlarms) {
showSnackbar("Section control ahead, limit ${section.speedLimit} m/s");
}
},
onEnterSpeedSectionAlarms: () {
showSnackbar("Entered ${alarmService!.speedSectionAlarms.length} section(s)");
},
onTravelSpeedSectionAlarms: () {
for (final section in alarmService!.speedSectionAlarms) {
showSnackbar(
"Average ${section.speedAvg} m/s, ${section.remainingDistance} m left");
}
},
onExitSpeedSectionAlarms: () {
for (final section in alarmService!.exitedSpeedSectionAlarms) {
showSnackbar("Left section, final average ${section.speedAvg} m/s");
}
},
);

alarmService = AlarmService(alarmListener);

Enable section alarms​

Section alarms are disabled by default and require the safety cameras overlay to be present in the alarm service overlays collection:

final service = alarmService!;

service.overlays.add(CommonOverlayId.safety.id);
service.enableSpeedSectionAlarm = true;

Check the current state with service.isSpeedSectionAlarmEnabled.

warning

Section alarms are produced only while navigating with a route. They are not emitted in free drive.

Read the active sections​

Read the corresponding getter on AlarmService to obtain the sections each notification refers to:

CallbackGetter to read
onApproachingSpeedSectionAlarmsapproachingSpeedSectionAlarms - sections coming up within the configured alarmDistance.
onEnterSpeedSectionAlarmsspeedSectionAlarms - sections the vehicle is currently inside.
onTravelSpeedSectionAlarmsspeedSectionAlarms - the same sections, with updated progress.
onExitSpeedSectionAlarmsexitedSpeedSectionAlarms - sections just left behind.
info

approachingSpeedSectionAlarms and exitedSpeedSectionAlarms are guaranteed not to be empty when read from their own notification.

speedSectionAlarms carries no such guarantee: it returns the sections currently active, and an empty list when none are. Iterate it rather than indexing into it.

warning

Overlay-based alarms need an active GemMap, and the loaded map style must contain the safety overlay. Without both, the section alarms do not work correctly.

SpeedSectionAlarm​

PropertyTypeDescription
entryOverlayItemThe section entry gantry overlay item.
exitOverlayItemThe section exit gantry overlay item.
totalDistanceintTotal enforced section length, in meters.
remainingDistanceintRemaining distance to the exit gantry, in meters.
speedLimitdoubleEnforced section speed limit, in meters per second.
speedAvgdoubleRunning average speed since the entry gantry, in meters per second.

Compare speedAvg against speedLimit to warn the driver while there is still distance left to compensate:

for (final section in alarmService!.speedSectionAlarms) {
if (section.speedAvg > section.speedLimit) {
showSnackbar(
"Over the section average, ${section.remainingDistance} m to the exit gantry");
}
}