Visual lane guidance
The HERE SDK supports visual lane guidance during turn-by-turn navigation to help drivers understand lane-level situations along a guided route.
This feature is intended for navigation scenarios where the application follows a Route with the VisualNavigator. It renders a route carpet that visualizes lane structure on the road and highlights the highly recommended lane (HLR) as a blue line to indicate where the driver should stay to follow the route.
If you are looking for lane data to build a custom lane UI, use the lane guidance APIs from the Get lane assistance chapter. Those APIs provide lane recommendations for the next maneuver (for example, recommended lanes and lane attributes), while physical lane-level road rendering comes from visual lane guidance. Visual lane guidance, in contrast, is a continuous on-road map rendering aid: it draws the route carpet and HLR directly on the road while guidance is active.
Note
Note that this is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
Visual lane guidance builds on a running turn-by-turn navigation session. To use it, make sure the following requirements are met:
- Make sure you have a Navigate license and a separate visual lane guidance license.
- Set a map scheme that supports lane rendering.
MapScheme.clusterDayis recommended. - Make sure
MapFeatureModes.terrain3dis disabled. - Set a supported camera behavior on the
VisualNavigator:TransitionCameraBehaviororAutomotiveCameraBehavior.AutomotiveCameraBehavioris recommended. - If you use offline maps, enable
LayerConfiguration.HD_LANES.
Visual lane guidance has the following limitations:
- Road types: Lane-level visualization is available on highways and freeways, including highway or freeway segments within cities.
- Roadworks: Lane-level visualization is not available on segments with road construction works. In this case, the guidance view can fall back to the standard navigation view.
- Coverage: The feature is available in North America (
NAR), West Europe (WEU), and East Europe (EEU).
The visual_lane_guidance_app example app on GitHub shows a possible implementation.
Step 1: Provide a route for guidance
Make sure guidance has a Route instance available before enabling visual lane guidance. Route calculation itself is covered in Calculate routes.
Step 2: Choose and initialize camera behaviors
Before implementing this step, choose how camera behavior should work for your guidance:
TransitionCameraBehaviorlets the HERE SDK automatically switch between lane-level visualization and the standard navigation view, based on route context and map data availability.AutomotiveCameraBehavioruses an automotive-style camera model and can be configured from a JSON asset for external tuning.
In this example, camera behavior setup is centralized in a dedicated CameraBehaviors class. The initialize() method creates both behaviors, sets AutomotiveCameraBehavior as default, and applies the active behavior to the VisualNavigator.
Future<void> initialize() async {
transitionCameraBehavior = TransitionCameraBehavior.withRecommendedConfiguration();
final configJson = await _loadAutomotiveCameraConfig();
automotiveCameraBehavior = AutomotiveCameraBehavior.fromJson(configJson);
automotiveCameraBehavior.activeCameraType = AutomotiveCameraBehaviorActiveCameraType.tracking;
activeCameraBehavior = automotiveCameraBehavior;
visualNavigator.cameraBehavior = activeCameraBehavior;
}Use TransitionCameraBehavior
Use TransitionCameraBehavior when you want the HERE SDK to switch automatically between lane-level visualization and the standard navigation view, based on the guided route and available map content.
Note
Note that
TransitionCameraBehavioris a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
void useTransitionCameraBehavior() {
activeCameraBehavior = transitionCameraBehavior;
visualNavigator.cameraBehavior = activeCameraBehavior;
}Use AutomotiveCameraBehavior
Use AutomotiveCameraBehavior when you want to apply an automotive-style camera model. This behavior can be created from a JSON asset so that the camera tuning is configured externally.
Note
Note that
AutomotiveCameraBehavioris a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
Create the camera behavior like below:
Future<String> _loadAutomotiveCameraConfig() async {
final raw = await rootBundle.loadString('assets/AutomotiveCameraConfig.json');
jsonDecode(raw);
return raw;
}Apply AutomotiveCameraBehavior like below:
void useAutomotiveCameraBehavior() {
automotiveCameraBehavior.activeCameraType = AutomotiveCameraBehaviorActiveCameraType.tracking;
activeCameraBehavior = automotiveCameraBehavior;
visualNavigator.cameraBehavior = activeCameraBehavior;
}The JSON asset used by this example is AutomotiveCameraConfig.json. This allows you to tune the automotive camera behavior externally instead of hardcoding all values in Dart. The loading code is shown above in the _loadAutomotiveCameraConfig() method.
Step 3: Start guidance with the VisualNavigator
Once a route is available and a camera behavior is selected, guidance can be started.
visualNavigator.startRendering(mapController);
visualNavigator.route = route;This is the point where visual lane guidance can become visible, provided that guidance is active and the route enters supported coverage.
Step 4: Feed location updates into the navigator
Feed location updates into VisualNavigator (for example, from a LocationSimulator).
final simulator = LocationSimulator.withRoute(route, options);
simulator.listener = visualNavigator;
simulator.start();Without location updates, route progress cannot be detected and no guidance-related visualization can be updated.
The visual_lane_guidance_app example app on GitHub shows how to calculate a route, start simulated guidance, use TransitionCameraBehavior for automatic mode switching based on map data availability, and switch to AutomotiveCameraBehavior configured from JSON.
Updated 9 hours ago