Road events
Navigation SDK UX Framework exposes the DashRoadInfoEvent
class to observe road data like lanes, directions, categories, etc. and speed limits.
class DashRoadInfoEvent internal constructor(
val roadInfo: DashRoadInfo?,
val speedLimit: DashSpeedLimit,
)
DashRoadInfo
contains the road description while driving.
class DashRoadInfo internal constructor(
val countryCodeIso2: String?,
val drivingSide: DashDrivingSide,
val isOneWay: Boolean,
val laneCount: Byte,
@DashRoadClass.Type val roadClass: String?,
)
countryCodeIso2
- the country code (ISO-2 format) of the road.drivingSide
- right-hand (DashDrivingSide.DRIVING_SIDE_RIGHT
) or left-hand (DashDrivingSide.DRIVING_SIDE_LEFT
) traffic type.isOneWay
- true if current road is one-way, otherwise false.laneCount
- the number of lanes on the road.roadClass
- classify road usingDashRoadClass
.
DashSpeedLimit
represents the current speed limit on the road.
class DashSpeedLimit internal constructor(
val speedLimitValue: Int?,
val speedUnit: DashSpeedLimitUnit,
)
speedLimitValue
- the value of the speed limit, otherwisenull
speedUnit
-DashSpeedLimitUnit.MILES_PER_HOUR
orDashSpeedLimitUnit.KM_PER_HOUR
The host application can observe the road info events through the Dash.controller
instance.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
Dash.controller.observeRoadInfoEvents()
.collect { /* DashRoadInfoEvent */ event ->
// Do something with the DashRoadInfoEvent
processRoadInfoEvents(event)
}
}
}
}
fun processRoadInfoEvents(event: DashRoadInfoEvent) {
Toast.makeText(
this,
"Showing road info: $event ",
Toast.LENGTH_SHORT
).show()
}
}
この{Type}は役に立ちましたか?