Routes
Use NaviHelper APIs to change the route option and request rerouting. Confirm the results in NaviHelperEventListener callbacks. For setting a destination, see Destinations.
Change the route option
RouteOption provides the following values.
| Value | Description |
|---|---|
RECOMMENDED | Recommended route |
SHORT_DISTANCE | Shortest-distance route |
SHORT_TIME | Shortest-time route |
FREE | Free-road-priority route |
HIGHWAY | Highway-priority route |
COMFORTABLE | Comfortable route |
SCHOOL_ZONE | School-zone-aware route |
You can set the option in RouteInfo.routeOption when first setting the destination, or change it during guidance with changeRouteOption().
- Kotlin
- Java
// Set destination
naviHelper.requestRoute(
RouteInfo(
latitude = 37.48544722,
longitude = 127.03636666,
displayLongitude = null,
displayLatitude = null,
poiName = "42dot",
poiId = "36khp37hh8gqcm5nqhe5",
poiSubId = "0",
address = "서울시 강남구 남부순환로 2621"
)
)
// Change route option to highway priority
naviHelper.changeRouteOption(RouteOption.HIGHWAY)
// Receive the changed data in the onRouteOptionChanged callback
override fun onRouteOptionChanged(routeOption: RouteOption) {
Log.d(logTag, "onRouteOptionChanged $routeOption")
}
// Cancel destination
naviHelper.cancelRoute()
// Set destination
naviHelper.requestRoute(new RouteInfo(
127.03636666,
37.48544722,
null,
null,
"42dot",
"36khp37hh8gqcm5nqhe5",
"서울시 강남구 남부순환로 2621",
"0",
RouteOption.RECOMMENDED
));
// Change route option to highway priority
naviHelper.changeRouteOption(RouteOption.HIGHWAY);
// Receive the changed data in the onRouteOptionChanged callback
@Override
public void onRouteOptionChanged(@NonNull RouteOption routeOption) {
Log.d(logTag, "onRouteOptionChanged = " + routeOption);
}
// Cancel destination
naviHelper.cancelRoute();
Request rerouting
Call requestReRoute() to request a route recalculation based on the current location and destination.
- Kotlin
- Java
// Set destination
naviHelper.requestRoute(
RouteInfo(
latitude = 37.48544722,
longitude = 127.03636666,
displayLongitude = null,
displayLatitude = null,
poiName = "42dot",
poiId = "36khp37hh8gqcm5nqhe5",
poiSubId = "0",
address = "서울시 강남구 남부순환로 2621"
)
)
// Request rerouting
naviHelper.requestReRoute()
// Cancel destination
naviHelper.cancelRoute()
// Set destination
naviHelper.requestRoute(new RouteInfo(
127.03636666,
37.48544722,
null,
null,
"42dot",
"36khp37hh8gqcm5nqhe5",
"서울시 강남구 남부순환로 2621",
"0",
RouteOption.RECOMMENDED
));
// Request rerouting
naviHelper.requestReRoute();
// Cancel destination
naviHelper.cancelRoute();
note
Request route option changes and rerouting only when an active route exists. The processing result and callbacks that are actually delivered may vary depending on the Navigation app state.