This example simulates turn-by-turn navigation along a computed route rendered on an interactive map, driving a virtual position from a departure point to a destination. It is the simulation counterpart of the Route Navigation example: the on-screen experience is identical - a top panel with the next-turn icon, distance and street name, a traffic panel when an event lies ahead, and a bottom panel with the estimated time of arrival, remaining travel time and remaining travel distance - but the position comes from the SDK's simulator instead of the device GPS.
Because the position is simulated, there is no need to request location permissions, enable location services, or wait for a valid GPS fix before starting.
MainActivity retains a single NavigationService and a NavigationListener. The listener receives the stream of navigation events: when the simulation starts, when the next instruction changes, when the status changes, when the destination is reached, on errors, and when a voice instruction should be played. The navRoute helper returns the route currently being simulated, which the UI uses to read the estimated time of arrival, remaining time and distance.
The simulation is started once the worldwide road map is downloaded and up to date. Unlike real navigation, there is no permission or GPS gating - the road-map listener clears itself and calls startSimulation directly.
SdkSettings.onWorldwideRoadMapSupportStatus ={ status ->
if(status == EOffboardListenerStatus.UpToDate){
SdkSettings.onWorldwideRoadMapSupportStatus ={}
startSimulation()
}
}
startSimulation defines the departure and destination waypoints and calls navigationService.startSimulation with the navigation and routing-progress listeners. The call returns synchronously whether the simulation could be started; on failure the error is reported in a dialog. Here the simulated trip runs from London to Paris.
When the simulation starts (the onNavigationStarted callback above), the route is drawn on the map with presentRoute, the map selection cursor is disabled, the camera enters follow mode with followPosition, and the navigation panels are made visible. enableGPSButton wires the follow button and the follow-mode transitions: when the user pans away from the simulated position the button reappears and the panels are hidden; tapping the button calls followPosition to re-center and resume following. The active-state check here uses navigationService.isSimulationActive() rather than the real-navigation equivalent.
Each time the SDK reports a new instruction through onNavigationInstructionUpdated, updateNavigationInstruction refreshes the top panel. The displayable values are gathered on the SDK thread by collectNavigationUiData: the next street name (or turn instruction), the next-turn icon, the distance to the turn, and the estimated time of arrival / remaining travel time (RTT) / remaining travel distance (RTD) read from the simulated route. It also resolves a signpost image, falling back to a road-code shield when there is no signpost. The remaining travel time is colored orange or red according to the traffic severity; if it stays black there is no traffic delay on the route.
The estimated time of arrival, remaining travel time and remaining travel distance are derived from the route's timeDistance, adding any traffic delay where relevant.
After updating the instruction, updateNavigationInstruction also refreshes the traffic panel via updateTrafficPanel. It looks for the nearest traffic event ahead on the route that adds a delay; if none is found (or the top panel is hidden) the panel is hidden. getTrafficEvent walks the route's traffic events and computes, from the remaining travel distance, whether each event is still ahead or whether the simulated position is already inside it - which determines whether the panel shows the distance to the event or the distance remaining inside it.
When the destination is reached (onDestinationReached) or an error occurs (onNavigationError), onNavigationEnded hides the navigation panels, disables the follow button and removes the route, showing a dialog only for genuine errors (not for a normal cancellation).