public class AMapNavi
extends java.lang.Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
SLOPE_TYPE_DOWN |
static int |
SLOPE_TYPE_UP |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addAimlessModeListener(AimlessModeListener listener)
注册巡航模式信息回调监听
注意:该接口仅驾车模式有效
Register aimless mode information callback listener Note: This interface is only valid for driving mode. |
void |
addAMapNaviListener(AMapNaviListener naviListener)
添加导航事件回调监听。
|
void |
addParallelRoadListener(ParallelRoadListener listener)
添加平行路切换监听,包括主辅路切换和高架上下切换
注意:该接口仅驾车模式有效
Add parallel road switch listener, including main auxiliary road switching and overpass up-down switching Note: This interface is only valid for driving mode. |
static void |
addTTSInitializeListener(TTSInitializeListener ttsInitializeListener)
添加内置语音初始化监听
"Add a built-in voice initialization listener." |
void |
addTTSPlayListener(TTSPlayListener listener)
添加内置语音播报监听
Add built-in TTS playback listener |
boolean |
calculateDriveRoute(java.util.List<NaviLatLng> to,
java.util.List<NaviLatLng> wayPoints,
int strategy)
计算驾车路径(不带起点,起点默认为当前位置)
Calculate the driving route without specifying the starting point, which defaults to the current location. |
boolean |
calculateDriveRoute(java.util.List<NaviLatLng> from,
java.util.List<NaviLatLng> to,
java.util.List<NaviLatLng> wayPoints,
int strategy)
计算驾车路径(包含起点)
Calculate the driving route including the starting point. |
boolean |
calculateDriveRoute(NaviPoi fromPoi,
NaviPoi toPoi,
java.util.List<NaviPoi> wayPoints,
AMapNaviCalRouteOptions calRouteOptions)
算路参数支持传option,方便扩展算路参数
Routing parameters support passing options for easy extension of routing parameters AMapNaviCalRouteOptions 当前支持设置 strategy 和 invoker,后期按需要增加字段 |
boolean |
calculateDriveRoute(NaviPoi fromPoi,
NaviPoi toPoi,
java.util.List<NaviPoi> wayPoints,
int strategy)
驾车POI算路
Driving POI route calculation. |
boolean |
calculateDriveRoute(NaviPoi fromPoi,
NaviPoi toPoi,
java.util.List<NaviPoi> wayPoints,
int strategy,
AMapCalculateRouteListener listener) |
boolean |
calculateDriveRoute(java.lang.String toPoiId,
java.util.List<java.lang.String> wayPointIds,
int strategy)
计算驾车路径(不带起点,起点默认为当前位置)。
|
boolean |
calculateDriveRoute(java.lang.String fromPoiId,
java.lang.String toPoiId,
java.util.List<java.lang.String> wayPoints,
int strategy)
计算驾车路径(包含起点)
Calculates the driving route including the starting point. |
boolean |
calculateEleBikeRoute(NaviLatLng to)
骑行(电动车)经纬度算路 (不带起点,默认为当前位置)
Electric bicycle route calculation based on latitude and longitude (without a specified starting point, defaults to current position). |
boolean |
calculateEleBikeRoute(NaviLatLng from,
NaviLatLng to)
骑行(电动车)经纬度算路
Electric bicycle route calculation based on latitude and longitude. |
boolean |
calculateEleBikeRoute(NaviPoi fromPoi,
NaviPoi toPoi,
TravelStrategy strategy)
骑行(电动车)POI算路
Calculate electric bike route based on POIs. |
boolean |
calculateRideRoute(NaviLatLng to)
骑行(自行车)经纬度算路 (不带起点,默认为当前位置)
Cycling (bicycle) route calculation based on latitude and longitude (without starting point, defaulting to current position). |
boolean |
calculateRideRoute(NaviLatLng from,
NaviLatLng to)
骑行(自行车)经纬度算路 (包含起点)。
|
boolean |
calculateRideRoute(NaviPoi fromPoi,
java.util.List<NaviPoi> wayPoints,
NaviPoi toPoi,
TravelStrategy strategy)
骑行(自行车)POI算路 特别注意:当前接口为收费接口,您如果申请试用或者正式应用都请通过工单系统提交商务合作类工单进行沟通 https://lbs.amap.com/
Cycling (bicycle) route calculation via POIs. |
boolean |
calculateRideRoute(NaviPoi fromPoi,
NaviPoi toPoi,
TravelStrategy strategy)
骑行(自行车)POI算路
Calculate route using POIs for cycling (bicycle). |
boolean |
calculateWalkRoute(NaviLatLng to)
计算步行路径(不带起点,默认为当前位置)。
|
boolean |
calculateWalkRoute(NaviLatLng from,
NaviLatLng to)
计算步行路径(包含起点)。
|
boolean |
calculateWalkRoute(NaviPoi fromPoi,
java.util.List<NaviPoi> wayPoints,
NaviPoi toPoi,
TravelStrategy strategy)
步行POI算路 特别注意:当前接口为收费接口,您如果申请试用或者正式应用都请通过工单系统提交商务合作类工单进行沟通 https://lbs.amap.com/
Walking POI routing note: This interface is currently a paid service. |
boolean |
calculateWalkRoute(NaviPoi fromPoi,
NaviPoi toPoi,
TravelStrategy strategy)
步行POI算路
Calculate walking route using POIs |
int |
calculateWalkRouteReturnRequestId(NaviLatLng to) |
static void |
destroy()
释放导航对象资源
Release the resources of the navigation object. |
static int |
getAppLang() |
static AudioOutputMode |
getAudioOutputMode()
获取当前TTS播报类型
Get current TTS broadcast mode |
int |
getBroadcastMode()
获取设置的播报模式,设置播报模式都从该处获取值,控制UI
|
int |
getControlMusicVolumeMode()
获取导航语音播报混合音状态
Get the status of mixed sound for navigation voice announcements |
static java.lang.String |
getDeviceId(Context context)
获取设备唯一ID,使用导航SDK的时候建议使用这个作为设备唯一ID
Get the unique device ID, when using the navigation SDK, it is recommended to use this as the unique device ID |
int |
getEngineType()
获得导航引擎类型
Get navigation engine type. |
static AMapNavi |
getInstance(Context context)
创建一个AMapNavi导航对象
Create an instance of the AMapNavi navigation object. |
boolean |
getIsNaviTravelView()
已过时。
|
boolean |
getIsUseExtraGPSData()
获取是否使用外部定位数据
Get whether external positioning data is being used |
boolean |
getIsUseInnerVoice()
获取是否使用内部语音播报
Get whether internal voice announcements are used |
boolean |
getListenToVoiceDuringCall()
获取当前通话过程中是否进行导航播报(只在使用内置语音时生效)
Get whether navigation announcements occur during calls (only effective when using built-in voice) |
java.util.List<AMapNaviGuide> |
getNaviGuideList()
已过时。
请使用
AMapNaviPath.getNaviGuideList()Deprecated: Use AMapNaviPath.getNaviGuideList() instead |
AMapNaviPath |
getNaviPath()
获取当前规划的路线方案(路线结果),驾车、骑行与步行共用这一个对象
Get the currently planned route plan (route result), which is shared among driving, cycling, and walking modes. |
java.util.HashMap<java.lang.Integer,AMapNaviPath> |
getNaviPaths()
获取计算的多条路径
Get multiple calculated routes |
AMapNaviResourceProxy |
getNaviResourceProxy() |
NaviSetting |
getNaviSetting()
获取导航配置类
Get navigation settings class |
int |
getNaviType()
获取导航位置变化驱动类型
Get the type of navigation location change driver. |
boolean |
getRestrictareaInfo(AMapNaviPath path,
AMapNaviRestrictAreaInfoListener observer)
获取现行信息数据
Get current traffic information data |
boolean |
getServiceAreaDetailsEnable()
是否开启服务区详情开关
Whether to turn on the service area detail switch |
java.util.List<AMapTrafficStatus> |
getTrafficStatuses(int startPos,
int distance)
已过时。
已废弃,请使用
AMapNaviPath.getTrafficStatuses()Deprecated, please use AMapNaviPath.getTrafficStatuses() |
static TTSInitializeListener |
getTTSInitializeListener()
获取内置语音初始化监听
Get built-in voice initialization monitoring |
static java.lang.String |
getVersion()
获取版本号
Get version number |
boolean |
independentCalculateRoute(NaviPoi fromPoi,
NaviPoi toPoi,
java.util.List<NaviPoi> wayPoints,
int strategy,
int transportType,
AMapNaviIndependentRouteListener observer)
POI独立算路 SDK9.4.0版本开始支持骑步行途径点算路,骑步行添加途径点算路为付费接口。
|
boolean |
isGpsReady()
获取手机卫星定位是否准备就绪
Check if mobile satellite positioning is ready |
static boolean |
isTtsPlaying()
当前SDK内置语音的是否正在播报
Whether the built-in TTS of the current SDK is broadcasting. |
void |
pauseNavi()
暂停导航,仅支持模拟导航
Pause navigation, only supports simulated navigation. |
boolean |
playTTS(java.lang.String tts,
boolean forcePlay)
播放自定义文字,注意如果当前正在播放导航语音,可能导致播放失败,只在内置语音下生效
Play custom text, note that if the navigation voice is currently playing, it may cause playback failure, effective only under built-in voice |
boolean |
pushRouteGuideWithData(JSONObject serverData,
NaviPoi start,
NaviPoi end,
java.util.List<NaviPoi> wayPois,
int strategy,
AMapCalculateRouteListener listener) |
void |
pushTrajectoryRestoration(Context context,
java.util.List<com.amap.api.maps.model.LatLng> points,
java.util.List<com.amap.api.maps.model.LatLng> wayPoints,
java.lang.String vehicleType,
java.lang.String strategy,
TrajectoryRestorationTaskCallback taskCallback)
轨迹还原
|
boolean |
readNaviInfo()
触发一次导航播报提示
Trigger one navigation announcement prompt. |
boolean |
readTrafficInfo(int frontDistance)
触发一次前方路况播报
Trigger a road condition broadcast ahead once. |
boolean |
reCalculateRoute(int strategy)
导航过程中重新规划路线(起点为当前位置,途经点、终点位置不变)
Re-plan the route during navigation (the starting point is the current location, passing points and destination remain unchanged) |
int |
reCalculateRouteReturnRequestId(int strategy) |
void |
removeAimlessModeListener(AimlessModeListener listener)
移除巡航模式信息回调监听
注意:该接口仅驾车模式有效
Remove aimless mode information callback listener Note: This interface is only valid for driving mode. |
void |
removeAMapNaviListener(AMapNaviListener naviListener)
移除导航对象的监听
Remove the listener from the navigation object. |
void |
removeParallelRoadListener(ParallelRoadListener listener)
移除平行路切换监听,包括主辅路切换和高架上下切换
注意:该接口仅驾车模式有效
Remove parallel road switch listener, including main auxiliary road switching and overpass up-down switching Note: This interface is only valid for driving mode. |
void |
removeTTSPlayListener(TTSPlayListener listener)
移除内置语音播报监听
Remove built-in TTS playback listener |
void |
resumeNavi()
继续导航,仅支持模拟导航
Resume navigation, only supports simulated navigation. |
boolean |
selectRouteId(int id)
导航前选主路线
Select main route before navigation. |
void |
setAMapNaviOnlineCarHailingType(AMapNaviOnlineCarHailingType type)
设置网约车导航模式,包括非网约车模式,网约车接驾模式、网约车送驾模式,默认为非网约车模式
Set online car-hailing navigation mode, including non-online car-hailing mode, pick-up mode, drop-off mode, default is non-online car-hailing mode. |
static void |
setApiKey(Context context,
java.lang.String apiKey)
手动设置key,这是个静态方法,需要在一切导航接口前调用,建议在applicaiton中调用
Manually set the key, this is a static method, needs to be called before all navigation interfaces, it's recommended to call it in the application. |
static void |
setAppLang(Context context,
AMapNaviAppLangOptions aMapNaviAppLangOptions,
AudioAuthTaskCallback audioAuthTaskCallback)
设置app语言类型, 要确保AMapNavi创建前设置
Set app language type, ensure AMapNavi is created before setting |
static void |
setAudioOutputMode(AudioOutputMode audioMode) |
boolean |
setBroadcastMode(int mode)
设置语音播报模式为"专家模式"还是"新手模式"【驾车有效】,导航中设置需要下次算路才生效,如偏航或刷新重算
Set voice broadcast mode to "Expert Mode" or "Beginner Mode" [valid for driving], settings during navigation take effect after recalculating the next route, such as rerouting or refreshing recalculation. |
void |
setCameraInfoUpdateEnabled(boolean enable)
已过时。
已废弃,新引擎机制不再支持单播报模块控制
Deprecated, new engine mechanisms no longer support single module control for announcements |
void |
setCarInfo(AMapCarInfo carInfo)
设置车辆信息(包括车型,车牌,车高,车重等),路径规划时会躲避车辆限行区域和路线
Set vehicle information (including vehicle type, license plate, height, weight, etc.), and during path planning, it will avoid areas and routes where the vehicle is restricted. |
void |
setConnectionTimeout(int connectionTimeOut)
设置建立连接超时时间,单位毫秒级,最低3000,默认10000
Set the timeout for establishing a connection, unit in milliseconds, minimum 3000, default 10000. |
void |
setControlMusicVolumeMode(int controlMusicVolumeMode)
设置导航播报时压低音乐、暂停音乐,只有在使用内置语音时生效(Android8.0以下系统不支持暂停音乐,设置暂停音乐无效)
Set the volume mode for music when navigating, only effective when using internal voice (systems below Android 8.0 do not support pausing music, setting pause music is ineffective) |
void |
setEmulatorNaviSpeed(int speed)
设置模拟导航的速度
Set the simulated navigation speed. |
void |
setExtraGPSData(int type,
Location location)
此方法用于设置外部定位数据,并使用外部定位数据进行导航
This method sets external positioning data and navigates using it. |
void |
setGpsWeakDetecedInterval(long delayTime)
已过时。
此接口已失效
This interface is deprecated. |
void |
setInnerOptRecordEnable(java.lang.String key)
【二环专用】设置是否启用OPT日志记录
【Special for ErHuan】Set whether to enable OPT log recording |
void |
setIsNaviTravelView(boolean isTravel)
已过时。
|
void |
setIsOpenTrafficLight(java.lang.String key)
设置是否显示红绿灯倒计时
Set whether to display traffic light countdown |
void |
setIsUseExtraGPSData(boolean isUseExtraData)
设置是否使用外部定位数据
Set whether to use external GPS data. |
void |
setListenToVoiceDuringCall(boolean isListenToVoiceDuringCall)
设置在通话过程中是否进行导航播报,只有在使用内置语音时生效
Set whether navigation announcements should occur during calls, effective only when using built-in voice |
void |
setMultipleRouteNaviMode(boolean multipleRouteNaviMode)
设置多路线导航模式(导航中拥有若干条备选路线供用户选择), 或单路线导航模式(默认模式)
Set multi-route navigation mode (with several alternative routes available for users to choose from) or single route navigation mode (default mode). |
void |
setNaviNetworkProxy(AMapNaviNetWorkProxy proxy)
设置导航外部网络代理类
Set navigation external network proxy class |
void |
setNaviResourceProxy(AMapNaviResourceProxy proxy)
设置导航外部资源代理类
Set up the navigation external resource proxy class. |
static void |
setNetWorkingProtocol(NetWorkingProtocol protocol)
设置网络请求协议
Set network request protocol. |
void |
setNewExtraGPSData(int type,
com.amap.api.location.AMapLocation aMapLocation)
此方法用于新定位sdk涉及设置外部定位数据,并使用外部定位数据进行导航
使用此方法前需要先调用
AMapNavi.setIsUseExtraGPSData(boolean)将开关打开. |
void |
setServiceAreaDetailsEnable(boolean enable)
设置服务区详情是否打开,打开后组件会显示服务区UI,API会返回服务区类型信息
Set whether to open service area details, after opening, the component will display the service area UI, and the API will return the type information of the service area. |
void |
setSoTimeout(int soTimeOut)
设置服务器返回超时时间,单位毫秒级,最低3000,默认10000
Set server response timeout time, unit in milliseconds, minimum 3000, default 10000. |
void |
setTrafficInfoUpdateEnabled(boolean enable)
设置是否打开移动交通台功能
Set whether to open the mobile traffic station function. |
void |
setTrafficStatusUpdateEnabled(boolean enable)
设置交通状态是否更新
Set whether to update traffic status. |
void |
setTravelInfo(AMapTravelInfo travelInfo)
设置骑步行信息(骑行、步行)
Set cycling or walking information. |
void |
setTruckMultipleRouteNaviMode(boolean truckMultipleRouteNaviMode)
设置货车多路线导航模式(导航中拥有若干条备选路线供用户选择), 或单路线导航模式(默认模式)
Set the multi-route navigation mode for trucks (where there are several alternative routes available for users to choose from) or single route navigation mode (default mode) 注意:此方法仅限于在开始导航前调用有效,步行与骑行导航无效,以下情况不会出现多备选路线:模拟导航、路线存在途经点、路线长度超过80KM。 |
static void |
setTtsPlaying(boolean playing)
设置外部播放器是否正在播报
Set whether the external player is currently broadcasting. |
void |
setUseInnerVoice(boolean isUseInnerVoice)
已过时。
|
void |
setUseInnerVoice(boolean isUseInnerVoice,
boolean isCallBackText)
设置使用内部语音播报
Set internal voice announcement usage |
void |
startAimlessMode(int aimlessMode)
设置在巡航模式(无路线规划)的状态下,智能播报的类型
Set the type of smart announcements in cruise mode (without route planning). |
boolean |
startGPS()
启动手机卫星定位
Start satellite positioning on the phone. |
boolean |
startGPS(long interval)
启动手机卫星定位, 带定位时间间隔参数
Activate mobile satellite positioning with timing interval parameter. |
boolean |
startGPS(long time,
int dis)
已过时。
请使用
AMapNavi.startGPS(long)
Use AMapNavi.startGPS(long) instead. |
boolean |
startNavi(int naviType)
开始导航。
|
boolean |
startNaviWithPath(int naviType,
AMapNaviPathGroup pathGroup)
使用指定路线开始导航
Start navigation using a specified route |
void |
startSpeak()
开始内置语音播报,只有在使用内置语音的情况下才有效
Start internal voice broadcast, effective only when using internal voice |
void |
stopAimlessMode()
停止巡航模式
Stop cruise mode.
|
boolean |
stopGPS()
停止手机卫星定位
Stop mobile satellite positioning. |
void |
stopNavi()
停止导航,包含实时导航和模拟导航
Stop navigation, including real-time navigation and simulated navigation. |
void |
stopSpeak()
停止内置语音播报,只有在使用内置语音的情况下有效
Stop internal voice broadcast, effective only when using internal voice. |
int |
strategyConvert(boolean avoidCongestion,
boolean avoidHighway,
boolean avoidCost,
boolean prioritiseHighway,
boolean multipleRoute)
进行算路策略转换,将传入的特定规则转换成PathPlanningStrategy的枚举值
Perform route planning strategy conversion, converting the specific rules passed into enum values of PathPlanningStrategy. |
void |
switchParallelRoad()
已过时。
|
void |
switchParallelRoad(int parallelType)
切换平行路,目前支持主辅路和高架上下切换
Switch parallel roads, currently supports main and auxiliary road switching and overpass up and down switching. |
public static final int SLOPE_TYPE_UP
public static final int SLOPE_TYPE_DOWN
public static AMapNavi getInstance(Context context) throws com.amap.api.maps.AMapException
context - 对应的Contextcom.amap.api.maps.AMapExceptionpublic static java.lang.String getVersion()
public static void setApiKey(Context context,
java.lang.String apiKey)
context - 对应的ContextapiKey - 用户在高德官网申请的KEYpublic static void setTtsPlaying(boolean playing)
如果正在播报语音,请设置为true,如果没有在播报语音,请设置false;如一直设置true,SDK内部会认为外界一直在播报,
那么AMapNaviListener.onGetNavigationText(int, String),就会一直不触发,导致无文字吐出;
如一直设置false,文字吐出的频率可能会过快,会出现语句打断情况,所以请根据实际情况设置。
AMapNaviListener.onGetNavigationText(int, String) will not trigger, resulting in no text output;
if consistently set to false, the frequency of text output might be too fast, causing interruptions in sentences, so please adjust based on actual conditions.
playing - true-外部播放器正在播报中,false-外部播放器空闲中public static boolean isTtsPlaying()
注意:正在播报的时候请不要使用外部播放器播报语音,会导致与导航内置的播报冲突。
Note: When broadcasting, do not use the external player to broadcast voice, which can cause conflicts with the internal broadcasting of navigation.
public int strategyConvert(boolean avoidCongestion,
boolean avoidHighway,
boolean avoidCost,
boolean prioritiseHighway,
boolean multipleRoute)
注意:该接口仅驾车模式有效
Note: This interface is valid only for driving mode.
avoidCongestion - 是否躲避拥堵avoidHighway - 是否不走高速
whether to avoid expresswaysavoidCost - 是否避免收费prioritiseHighway - 是否高速优先multipleRoute - 单路径or多路径,6.3版本以后该参数已经无效,统一使用多路线算路。public static void destroy()
退出时调用此接口释放导航资源,在调用此接口后不能再调用AMapNavi类里的其它接口。
Exit and call this interface to release navigation resources; after calling this interface, no other interfaces in the AMapNavi class can be called.
public boolean startNavi(int naviType)
naviType - 导航类型,1:实时导航 2:模拟导航。public boolean startNaviWithPath(int naviType,
AMapNaviPathGroup pathGroup)
public void pauseNavi()
public void stopNavi()
public void resumeNavi()
public boolean readNaviInfo()
注意:该接口仅驾车和步行模式有效
Note: This interface is only valid for driving and walking modes.
public boolean readTrafficInfo(int frontDistance)
注意:该接口仅驾车模式有效
Note: This interface is only valid for driving mode.
frontDistance - 要播报的前方路径距离,0为SDK默认距离,-1为整条路径,一般情况下前方路况播报设置为0。public boolean calculateDriveRoute(java.util.List<NaviLatLng> from, java.util.List<NaviLatLng> to, java.util.List<NaviLatLng> wayPoints, int strategy)
from - 指定的导航起点。支持多个起点,起点列表的尾点为实际导航起点,其他坐标点为辅助信息,带有方向性,可有效避免算路到马路的另一侧;to - 指定的导航终点。支持多个终点,终点列表的尾点为实际导航终点,其他坐标点为辅助信息,带有方向性,可有效避免算路到马路的另一侧。wayPoints - 途经点,同时支持最多16个途经点的路径规划;strategy - 规划策略,详情参见 PathPlanningStrategy。普通客车、货车请使用"DRIVING_"开头的策略,驾车推荐使用默认策略 PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT,摩托车请使用"MOTOR_"开头的策略。PathPlanningStrategy. For regular passenger cars and trucks, use strategies starting with "DRIVING_". Driving is recommended to use the default strategy PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT, motorcycles should use strategies starting with "MOTOR_".public boolean calculateDriveRoute(java.util.List<NaviLatLng> to, java.util.List<NaviLatLng> wayPoints, int strategy)
to - 指定的导航终点。支持多个终点,终点列表的尾点为实际导航终点,其他坐标点为辅助信息,带有方向性,可有效避免算路到马路的另一侧。wayPoints - 途经点,同时支持最多16个途经点的路径规划。strategy - 规划策略,详情参见 PathPlanningStrategy。普通客车、货车请使用"DRIVING_"开头的策略,驾车推荐使用默认策略 PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT,摩托车请使用"MOTOR_"开头的策略。PathPlanningStrategy. Regular passenger vehicles and trucks should use strategies starting with "DRIVING_", driving is recommended to use the default strategy PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT, motorcycles should use strategies starting with "MOTOR_".public boolean calculateDriveRoute(java.lang.String fromPoiId,
java.lang.String toPoiId,
java.util.List<java.lang.String> wayPoints,
int strategy)
fromPoiId - 指定的导航起点Poi的Id;toPoiId - 指定的导航终点Poi的Id;wayPoints - 途经点Poi,同时支持最多16个途经点的路径规划;strategy - 规划策略,详情参见 PathPlanningStrategy。普通客车、货车请使用"DRIVING_"开头的策略,驾车推荐使用默认策略 PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT,
摩托车请使用"MOTOR_"开头的策略。PathPlanningStrategy. Use strategies starting with "DRIVING_" for regular passenger vehicles and trucks, driving is recommended to use the default strategy PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT,
Motorcycles should use strategies starting with "MOTOR_".AMapNaviListener算路成功回调。AMapNaviListener.public boolean calculateDriveRoute(java.lang.String toPoiId,
java.util.List<java.lang.String> wayPointIds,
int strategy)
AMapNavi.startGPS()开启定位,获取算路的起点AMapNavi.startGPS() to enable positioning and obtain the starting point for calculating the route.toPoiId - 指定的导航终点Poi的Id;wayPointIds - 途经点Poi id,同时支持最多16个途经点的路径规划;strategy - 规划策略,详情参见 PathPlanningStrategy。普通客车、货车请使用"DRIVING_"开头的策略,驾车推荐使用默认策略 PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT,摩托车请使用"MOTOR_"开头的策略。PathPlanningStrategy. For regular passenger vehicles and trucks, use strategies starting with "DRIVING_", driving is recommended to use the default strategy PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT,
Motorcycles should use strategies starting with "MOTOR_".AMapNaviListener算路成功回调。AMapNaviListener.public boolean calculateDriveRoute(NaviPoi fromPoi, NaviPoi toPoi, java.util.List<NaviPoi> wayPoints, int strategy)
该方法可以避免到达点问题导致的绕路,地铁等多出口类POI,也会导航到多个出口。
注意:NaviPoi对象中,优先使用Poi id进行算路,失败则使用经纬度进行算路。
This method can avoid detours caused by arrival point issues, and also navigates to multiple exits for multi-exit POIs such as subway stations.
Note: In the NaviPoi object, prioritize using Poi id for routing calculations, and fall back to using latitude and longitude if that fails.
fromPoi - 起点poi NaviPoi,若传入无效起点则使用当前位置NaviPoi, if an invalid starting point is passed, the current position will be usedtoPoi - 终点poi NaviPoiNaviPoiwayPoints - 途经点poi NaviPoiNaviPoistrategy - 规划策略,详情参见 PathPlanningStrategy。普通客车、货车请使用"DRIVING_"开头的策略,驾车推荐使用默认策略 PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT,摩托车请使用"MOTOR_"开头的策略。PathPlanningStrategy. Regular passenger vehicles and trucks should use strategies starting with "DRIVING_". Driving is recommended to use the default strategy PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT. Motorcycles should use strategies starting with "MOTOR_".public boolean calculateDriveRoute(NaviPoi fromPoi, NaviPoi toPoi, java.util.List<NaviPoi> wayPoints, int strategy, AMapCalculateRouteListener listener)
public boolean calculateDriveRoute(NaviPoi fromPoi, NaviPoi toPoi, java.util.List<NaviPoi> wayPoints, AMapNaviCalRouteOptions calRouteOptions)
public void setCarInfo(AMapCarInfo carInfo)
目前小客车算路只考虑车牌因素,货车算路会考虑车高、车重等信息,
其中AMapCarInfo.setRestriction(boolean)}用于控制是否规避限行路段。
AMapCarInfo.setVehicleLoadSwitch(boolean)用于控制算路时是否需要考虑车重。
注意:该接口仅驾车模式有效
Currently, when calculating routes for small cars, only the license plate factor is considered; for trucks, factors like vehicle height and weight are taken into account,
Among which, AMapCarInfo.setRestriction(boolean)} is used to control whether to avoid restricted driving sections.
AMapCarInfo.setVehicleLoadSwitch(boolean) is used to control whether to consider vehicle load during route calculation.
Note: This interface is only valid in driving mode.
carInfo - 车辆信息类public void setTravelInfo(AMapTravelInfo travelInfo)
travelInfo - 车辆信息类public boolean reCalculateRoute(int strategy)
strategy - 指定的驾车策略常量值,参见PathPlanningStrategy;骑步行忽略此参数,传0即可。PathPlanningStrategy;Cycling and walking ignore this parameter, pass 0.public int reCalculateRouteReturnRequestId(int strategy)
public java.util.List<AMapTrafficStatus> getTrafficStatuses(int startPos, int distance)
AMapNaviPath.getTrafficStatuses()AMapNaviPath.getTrafficStatuses()
注意:该接口仅驾车模式有效
Note: This interface is valid only for driving mode
startPos - 参数已无效,传入0即可distance - 参数已无效,传入0即可public AMapNaviPath getNaviPath()
public java.util.HashMap<java.lang.Integer,AMapNaviPath> getNaviPaths()
AMapNaviPath对象AMapNaviPath objectpublic java.util.List<AMapNaviGuide> getNaviGuideList()
AMapNaviPath.getNaviGuideList()AMapNaviPath.getNaviGuideList() insteadpublic NaviSetting getNaviSetting()
public void setEmulatorNaviSpeed(int speed)
驾车默认速度为60km/h,设置的模拟值区间应该在10-120之间.
步行默认速度为20km/h,设置的模拟值区间应该在10-30之间.
骑行默认速度为35km/h,设置的模拟值区间应该在10-50之间.
Default driving speed is 60 km/h, the simulated value range should be between 10-120.
Default walking speed is 20 km/h, the simulated value range should be between 10-30.
Default cycling speed is 35 km/h, the simulated value range should be between 10-50.
speed - 模拟导航的速度,单位:km/h。public void addAMapNaviListener(AMapNaviListener naviListener)
naviListener - 导航回调监听public void removeAMapNaviListener(AMapNaviListener naviListener)
naviListener - 监听listener。public boolean startGPS()
用户可以手动启动卫星定位功能,如果没有启动,在导航启动时(startNavi)会自动启动。默认定位时间间隔为1秒,变化距离为0。
Users can manually activate the satellite positioning function; if not activated, it will automatically start when navigation begins (startNavi). By default, the location update interval is 1 second, and the change distance is 0.
public boolean startGPS(long time,
int dis)
AMapNavi.startGPS(long)
Use AMapNavi.startGPS(long) instead.
用户可以手动启动手机卫星定位,如果没有启动,在导航启动时(startNavi)会自动启动。
Users can manually activate the satellite positioning function; if not activated, it will automatically start when navigation begins (startNavi).
time - 位置更新的时间间隔, 单位:毫秒。dis - 位置更新的距离间隔, 单位:米。此参数已无效。public boolean startGPS(long interval)
用户可以手动启动手机卫星定位,如果没有启动,在导航启动时(startNavi)内部会自动启动。
Users can manually activate the satellite positioning function; if not activated, it will automatically start internally when navigation starts (startNavi).
interval - 导航内部定位的时间间隔, 单位:毫秒。注意,该参数仅影响导航内部定位塞点的频率,与导航位置回调 AMapNaviListener.onLocationChange(AMapNaviLocation) 的频率无关。AMapNaviListener.onLocationChange(AMapNaviLocation).public boolean stopGPS()
public boolean calculateWalkRoute(NaviLatLng to)
to - 导航终点。调用此接口前需要调用AMapNavi.startGPS()开启定位,获取算路的起点。AMapNavi.startGPS() to enable positioning and obtain the starting point for routing.public int calculateWalkRouteReturnRequestId(NaviLatLng to)
public boolean calculateWalkRoute(NaviLatLng from, NaviLatLng to)
from - 导航起点。to - 导航终点。public boolean calculateWalkRoute(NaviPoi fromPoi, NaviPoi toPoi, TravelStrategy strategy)
fromPoi - 起点POItoPoi - 终点POIstrategy - 算路策略 TravelStrategyTravelStrategypublic boolean calculateWalkRoute(NaviPoi fromPoi, java.util.List<NaviPoi> wayPoints, NaviPoi toPoi, TravelStrategy strategy)
fromPoi - 起点POI,如果以“我的位置”作为起点,请传null。 如果fromPoi不为null,那么POIID合法,优先使用ID参与算路,否则使用坐标点。wayPoints - 途径点POI,最多支持16个途经点,超过16个会取前16个。如果POIID合法,优先使用ID参与算路。否则使用坐标点。注意:POIID和坐标点不能同时为空。toPoi - 终点POI,如果POIID合法,优先使用ID参与算路,否则使用坐标点。注意:POIID和坐标点不能同时为空。strategy - 路径的计算策略public boolean calculateRideRoute(NaviLatLng to)
to - 骑行终点。调用此接口前需要调用AMapNavi.startGPS()开启定位,获取算路的起点。AMapNavi.startGPS() to enable positioning and obtain the starting point for route calculation.public boolean calculateRideRoute(NaviLatLng from, NaviLatLng to)
from - 骑行起点。to - 导航终点。public boolean calculateRideRoute(NaviPoi fromPoi, NaviPoi toPoi, TravelStrategy strategy)
fromPoi - 起点POItoPoi - 终点POIstrategy - 算路策略 TravelStrategyTravelStrategy.public boolean calculateRideRoute(NaviPoi fromPoi, java.util.List<NaviPoi> wayPoints, NaviPoi toPoi, TravelStrategy strategy)
fromPoi - 起点POI,如果以“我的位置”作为起点,请传null. 如果fromPoi不为null,那么POIID合法,优先使用ID参与算路,否则使用坐标点wayPoints - 途径点POI,最多支持16个途经点,超过16个会取前16个。如果POIID合法。优先使用ID参与算路。否则使用坐标点。注意:POIID和坐标点不能同时为空toPoi - 终点POI,如果POIID合法,优先使用ID参与算路,否则使用坐标点。注意:POIID和坐标点不能同时为空strategy - 路径的计算策略public boolean calculateEleBikeRoute(NaviLatLng to)
to - 导航终点。public boolean calculateEleBikeRoute(NaviLatLng from, NaviLatLng to)
from - 骑行起点。起点传null,或经纬度为 0 时,使用当前位置作为起点。to - 导航终点。public boolean calculateEleBikeRoute(NaviPoi fromPoi, NaviPoi toPoi, TravelStrategy strategy)
fromPoi - 起点POItoPoi - 终点POIstrategy - 算路策略 TravelStrategyTravelStrategypublic int getEngineType()
EngineTypeEngineTypepublic int getNaviType()
public void startAimlessMode(int aimlessMode)
用户一旦设置,在巡航模式(无路线规划)的状态下,会获得以下回调:
Once set, under cruise mode (no route planning), the following callbacks will be received:
AimlessModeListener.onUpdateTrafficFacility(AMapNaviTrafficFacilityInfo[])可以用于获得道路设施(包括转弯提示等)
AimlessModeListener.onUpdateTrafficFacility(AMapNaviTrafficFacilityInfo[]) can be used to obtain road facilities information including turn prompts etc.
AimlessModeListener.onUpdateAimlessModeElecCameraInfo(AMapNaviTrafficFacilityInfo[])可以用于获得电子眼信息更新
AimlessModeListener.onUpdateAimlessModeElecCameraInfo(AMapNaviTrafficFacilityInfo[]) can be used to update electronic eye information.
AimlessModeListener.updateAimlessModeCongestionInfo(AimLessModeCongestionInfo)可以用于获得周边道路拥堵信息
AimlessModeListener.updateAimlessModeCongestionInfo(AimLessModeCongestionInfo) can be used to obtain surrounding traffic congestion information.
AimlessModeListener.updateAimlessModeStatistics(AimLessModeStat)可以用于巡航模式的统计信息,巡航开启时间,巡航移动距离
AimlessModeListener.updateAimlessModeStatistics(AimLessModeStat) can be used for cruise mode statistics, such as the time when cruise mode was activated and the distance moved during cruise.
AMapNaviListener.onGetNavigationText(int, String)可以用于获得巡航语音播报文字
AMapNaviListener.onGetNavigationText(int, String) can be used to receive voice announcement text during cruise mode.
aimlessMode - 巡航播报模式,详情见AimLessModeAimLessModepublic void stopAimlessMode()
注意:该接口仅驾车模式有效
Note: This interface is valid only in driving mode.
public void setConnectionTimeout(int connectionTimeOut)
connectionTimeOut - 超时时间public void setSoTimeout(int soTimeOut)
soTimeOut - 超时时间public boolean selectRouteId(int id)
注意:该接口仅驾车模式有效
Note: This interface is valid only in driving mode.
id - 路线的routeIdpublic boolean isGpsReady()
public boolean setBroadcastMode(int mode)
注意:该接口仅驾车模式有效
Note: This interface is valid only in driving mode.
mode - 参见BroadcastModeBroadcastModepublic int getBroadcastMode()
public void switchParallelRoad()
AMapNavi.switchParallelRoad(int)AMapNavi.switchParallelRoad(int)public void switchParallelRoad(int parallelType)
此函数只有在实时导航开始后才能使用,用来将路径的起点切换到当前导航路径平行的其它路径上
This function can only be used after real-time navigation starts, it switches the starting point of the path to another parallel path of the current navigation route
parallelType - 1-主辅路切换,2-高架上下切换public boolean getIsUseExtraGPSData()
public void setIsUseExtraGPSData(boolean isUseExtraData)
只有将此开关打开后,AMapNavi.setExtraGPSData(int, Location)方法才会生效。
Only after turning on this switch will the method AMapNavi.setExtraGPSData(int, Location) take effect.
isUseExtraData - 是否使用外部定位数据public void setExtraGPSData(int type,
Location location)
使用此方法前需要先调用AMapNavi.setIsUseExtraGPSData(boolean)将开关打开.
Before using this method, call AMapNavi.setIsUseExtraGPSData(boolean) to enable the feature.
type - 坐标类型。如果使用系统默认返回的定位坐标,type值为1。使用高德坐标,type值传2location - 外部定位数据。Longitude、Latitude、Accuracy、Speed、Bearing、Time 缺一不可public void setNewExtraGPSData(int type,
com.amap.api.location.AMapLocation aMapLocation)
AMapNavi.setIsUseExtraGPSData(boolean)将开关打开.type - 坐标类型。如果使用系统默认返回的定位坐标,type值为1。使用高德坐标,type值传2aMapLocation - 外部定位数据。Longitude、Latitude、Accuracy、Speed、Bearing、Time 缺一不可public void setUseInnerVoice(boolean isUseInnerVoice)
AMapNaviListener.onGetNavigationText(int, java.lang.String) 方法将不再回调AMapNaviListener.onGetNavigationText(int, java.lang.String) will no longer be triggered.isUseInnerVoice - 是否使用内部语音播报public void setUseInnerVoice(boolean isUseInnerVoice,
boolean isCallBackText)
isUseInnerVoice - 是否使用内部语音播报, 默认为false isCallBackText - 在将isUseInnerVoice设置为true之后,AMapNaviListener.onGetNavigationText(int, java.lang.String)接口将继续返回文本,默认为false AMapNaviListener.onGetNavigationText(int, java.lang.String) interface will continue to return text, default is falsepublic boolean getIsUseInnerVoice()
public void setMultipleRouteNaviMode(boolean multipleRouteNaviMode)
注意:此方法仅限于在开始导航前调用有效,步行与骑行导航无效,以下情况不会出现多备选路线:模拟导航、货车导航、路线存在途经点、路线长度超过80KM。
Note: This method is only effective before starting navigation, it does not apply to walking or cycling navigation. Multiple alternate routes will not appear under the following conditions: simulated navigation, truck navigation, routes with waypoints, or routes longer than 80KM.
注意:该接口仅驾车模式有效
Note: This interface is only valid for driving mode.
multipleRouteNaviMode - true:多路线导航模式, false:单路线导航模式(默认)public void setTruckMultipleRouteNaviMode(boolean truckMultipleRouteNaviMode)
注意:此方法仅限于在开始导航前调用有效,步行与骑行导航无效,以下情况不会出现多备选路线:模拟导航、路线存在途经点、路线长度超过80KM。
Note: This method is only effective before starting navigation, it does not apply to walking or cycling navigation. Multiple alternate routes will not appear under the following conditions: simulated navigation, routes with waypoints, or routes longer than 80KM.
注意:该接口仅货车导航有效
Note: This interface is only valid for truck navigation.
特别注意:当前接口为收费接口,您如果申请试用或者正式应用都请通过工单系统提交商务合作类工单进行沟通 https://lbs.amap.com/
Special note: This interface is a paid service. If you wish to apply for trial use or formal application, please submit a business cooperation ticket through the order system at https://lbs.amap.com/
truckMultipleRouteNaviMode - true:多路线导航模式, false:单路线导航模式(默认)public void addParallelRoadListener(ParallelRoadListener listener)
listener - public void removeParallelRoadListener(ParallelRoadListener listener)
listener - public void addAimlessModeListener(AimlessModeListener listener)
listener - public void removeAimlessModeListener(AimlessModeListener listener)
listener - public void addTTSPlayListener(TTSPlayListener listener)
listener - public void removeTTSPlayListener(TTSPlayListener listener)
listener - public void setGpsWeakDetecedInterval(long delayTime)
表示有连续的10s,卫星定位信号质量都比较差,就会触发手机卫星定位信号弱的回调。值越小,就越容易触发,
支持的时间间隔范围为5~15秒
It indicates that if the quality of the satellite positioning signal is poor continuously for 10 seconds, it will trigger a callback for weak mobile satellite signals. The smaller the value, the easier it triggers.
Supported time intervals range from 5 to 15 seconds.
delayTime - 时间间隔,单位为毫秒public void stopSpeak()
注意:7.1.0版本以后,调用该接口,会停止播放导航语音,但是仍然可以播放自定义语音
Note: After version 7.1.0, calling this interface will stop playing navigation voice but still allows custom voice playback
public void startSpeak()
public void setAMapNaviOnlineCarHailingType(AMapNaviOnlineCarHailingType type)
注意:该接口仅驾车模式有效
Note:This interface is only valid for driving mode
type - AMapNaviOnlineCarHailingTypepublic static void setNetWorkingProtocol(NetWorkingProtocol protocol)
注意,该接口仅控制导航业务相关的网络请求,不影响定位、地图sdk内部的请求。
Note: This interface only controls network requests related to navigation services and does not affect positioning or internal map sdk requests.
protocol - 请求协议枚举,详情见 NetWorkingProtocolNetWorkingProtocolpublic boolean playTTS(java.lang.String tts,
boolean forcePlay)
tts - 要播放的文字forcePlay - 是否强制进行播报public void pushTrajectoryRestoration(Context context,
java.util.List<com.amap.api.maps.model.LatLng> points,
java.util.List<com.amap.api.maps.model.LatLng> wayPoints,
java.lang.String vehicleType,
java.lang.String strategy,
TrajectoryRestorationTaskCallback taskCallback)
context - 对应的Contextpoints - 轨迹点。格式x1,y1|x2,y2。经纬度最多6位小数。wayPoints - 途经点。格式x1,y1|x2,y2。经纬度最多6位小数vehicleType - 车辆类型strategy - 驾车算路策略taskCallback - 任务执行结果回调public boolean pushRouteGuideWithData(JSONObject serverData,
NaviPoi start,
NaviPoi end,
java.util.List<NaviPoi> wayPois,
int strategy,
AMapCalculateRouteListener listener)
public static java.lang.String getDeviceId(Context context)
context - public boolean independentCalculateRoute(NaviPoi fromPoi, NaviPoi toPoi, java.util.List<NaviPoi> wayPoints, int strategy, int transportType, AMapNaviIndependentRouteListener observer)
fromPoi - 起点信息toPoi - 终点信息wayPoints - 途经点信息,最多支持16个途经点,超过16个会取前16个。如果POIID合法,优先使用ID参与算路,否则使用坐标点。注意:POIID和坐标点不能同时为空strategy - 算路策略: 驾车参考 PathPlanningStrategy, 骑步行参考 TravelStrategyPathPlanningStrategy; for cycling and walking, refer to TravelStrategy.transportType - 交通类型 1-驾车 2-骑行 3-步行observer - 算路结果监听器public boolean getRestrictareaInfo(AMapNaviPath path, AMapNaviRestrictAreaInfoListener observer)
path - 路线信息observer - 路线现行信息结果监听器public void setTrafficStatusUpdateEnabled(boolean enable)
需要动态交通信息相关功能时需要调用此接口打开交通信息功能,默认是开启的,
打开后会每1分钟请求一次新的交通信息来更新交通信息。关闭动态交通信息后使用交通信息的相关信息的功能将无法正常使用,包括路况刷新、避免拥堵重算等
When dynamic traffic information-related features are needed, call this interface to activate the traffic information feature, which is enabled by default.
After activation, new traffic information will be requested every minute to update the traffic status. Once the dynamic traffic information function is disabled, related functions such as road condition refresh and recalculation to avoid congestion will no longer work properly.
enable - true-更新路况,false-不更新路况public void setTrafficInfoUpdateEnabled(boolean enable)
默认是开启的,打开此功能后将有整体路况概览与前方路况播报功能,打开此功能后TBT会基本1分钟请求
一次前方路况(此时间间隔不是固定的)。关闭交通台后将没有路况播报功能
By default, it is turned on. After enabling this feature, there will be an overview of overall traffic conditions and announcements of upcoming traffic conditions.
After turning on this feature, TBT will basically request updates on upcoming traffic conditions once per minute (this time interval is not fixed). After disabling the traffic station, there will be no traffic announcement functionality.
enable - true-播报前方路况,false-不播报前方路况public void setCameraInfoUpdateEnabled(boolean enable)
初始电子眼播报是打开的,当电子眼播报打开时,电子眼数据中有限速信息时,同时会播报限速信息
Initially, the electronic eye broadcast is turned on. When the electronic eye broadcast is activated, if there is speed limit information in the electronic eye data, it will also announce the speed limit information
enable - true-播报前方电子眼,false-不播报前方电子眼public void setServiceAreaDetailsEnable(boolean enable)
注意: 该功能为高级功能, 如需开通请先联系对应商务开通权限
Note:This is a premium feature. Please contact the corresponding business representative to activate access rights.
enable - public boolean getServiceAreaDetailsEnable()
public void setListenToVoiceDuringCall(boolean isListenToVoiceDuringCall)
isListenToVoiceDuringCall - public boolean getListenToVoiceDuringCall()
public void setControlMusicVolumeMode(int controlMusicVolumeMode)
controlMusicVolumeMode - 0:压低音乐; 1:暂停音乐 AMapNaviControlMusicVolumeModeAMapNaviControlMusicVolumeModepublic int getControlMusicVolumeMode()
AMapNaviControlMusicVolumeModeAMapNaviControlMusicVolumeModepublic void setNaviNetworkProxy(AMapNaviNetWorkProxy proxy)
public void setIsNaviTravelView(boolean isTravel)
public boolean getIsNaviTravelView()
public void setInnerOptRecordEnable(java.lang.String key)
key - public void setIsOpenTrafficLight(java.lang.String key)
key - public static void setAppLang(Context context,
AMapNaviAppLangOptions aMapNaviAppLangOptions,
AudioAuthTaskCallback audioAuthTaskCallback)
context - 上下文aMapNaviAppLangOptions - 语言选项配置public static int getAppLang()
public void setNaviResourceProxy(AMapNaviResourceProxy proxy)
public AMapNaviResourceProxy getNaviResourceProxy()
public static void addTTSInitializeListener(TTSInitializeListener ttsInitializeListener)
注意事项:
Notes:
ttsInitializeListener - 监听对象 public static TTSInitializeListener getTTSInitializeListener()
public static AudioOutputMode getAudioOutputMode()
public static void setAudioOutputMode(AudioOutputMode audioMode)