Advanced Features
The AmapNaviParams class provides a variety of configuration methods that can be passed when launching the navigation component, enabling customization to meet specific requirements.
Launch Configuration
Skip Route Calculation
If a route has already been calculated externally using AMapNavi, you can choose to launch the component without recalculating, using the existing route for navigation.
/**
* Sets whether to calculate a route when launching the component for direct navigation.
* (Only takes effect when directly navigating to the navigation page.)
*
* @param needCalculateRouteWhenPresent true: calculate route; false: start navigation
* without route calculation. Default is true.
* @since 5.6.0
*/
public AmapNaviParams setNeedCalculateRouteWhenPresent(boolean needCalculateRouteWhenPresent)Choose the Launch Page
You can choose whether to launch the navigation interface or the route planning interface.
// The last parameter determines the page type:
// AmapPageType.NAVI for the navigation interface
// AmapPageType.ROUTE for the route planning interface
AmapNaviParams amapNaviParams = new AmapNaviParams(start, poiList, end, AmapNaviType.DRIVER, AmapPageType.NAVI);Stop and Destroy Navigation on Exit
Configure whether to stop and destroy the navigation instance when exiting the navigation component.
/**
* Sets whether to destroy the navigation instance when exiting the navigation component.
*
* @param destroy true: stop navigation when exiting the navigation page,
* and destroy navigation when exiting the component.
* false: when navigating directly within the component,
* exiting the navigation page does not stop navigation,
* and exiting the component does not destroy navigation.
* @since 5.6.0
*/
public AmapNaviParams setNeedDestroyDriveManagerInstanceWhenNaviExit(boolean destroy)Other Important Configuration Parameters
/**
* Sets whether to use the built-in voice broadcast.
*
* Note: Starting from version 6.1.0, the default value is true.
*
* @param isUseInnerVoice whether to use the built-in voice broadcast
* @since 6.0.0
*/
public AmapNaviParams setUseInnerVoice(boolean isUseInnerVoice)
/**
* Sets the route planning strategy for the component.
* Default: {@link com.amap.api.navi.enums.PathPlanningStrategy#DRIVING_MULTIPLE_ROUTES_DEFAULT}
* (Speed priority + avoid congestion + shorter distance).
* Note: Only multi-route strategies are supported.
*
* @param routeStrategy {@link com.amap.api.navi.enums.PathPlanningStrategy}
*/
public AmapNaviParams setRouteStrategy(int routeStrategy)
/**
* Sets the broadcast mode.
*
* @param context
* @param mode 1: concise broadcast; 2: detailed broadcast; 3: silent mode
* @since 7.1.0
*/
public AmapNaviParams setBroadcastMode(Context context, int mode)
/**
* Sets the navigation perspective.
*
* @param context
* @param mode 1: north-up; 2: heading-up
* @since 7.1.0
*/
public AmapNaviParams setCarDirectionMode(Context context, int mode)
/**
* Enables or disables the auto-scaling of the scale bar.
*
* @param context
* @param enable
* @since 7.1.0
*/
public AmapNaviParams setScaleAutoChangeEnable(Context context, boolean enable)