{"version":"0.1.0","code":"0000","result":true,"message":"处理成功","errdetail":"","timestamp":1671508880751,"data":{"id":71712167,"title":"7.5 沿途搜索","slug":"ne5wm9","format":"lake","bookId":26046811,"body":null,"body_draft":null,"body_html":"
沿途搜的前提条件,需要算出一条路线,通过取路线上的抽稀点或道路ID进行搜索。目前AutoSDK支持加油站、中石化、中石油、壳牌、美孚、ATM(不区分大小写)、维修站、厕所、充电站、加气站、美食、停车场、服务区的沿途POI搜索,其他类型可以通过category字段传入对应的typecode来实现。
离线沿途搜索支持的类别:
序号 | 类别编码 | 类别名称 | 序号 | 类别编码 | 类别名称 | |
1 | 10100 | 加油站 | 56 | 31302 | 东风雪铁龙维修 | |
2 | 10101 | 中国石化 | 57 | 31303 | DS维修 | |
3 | 10102 | 中国石油 | 58 | 31400 | 三菱维修 | |
4 | 10103 | 壳牌 | 59 | 31401 | 广汽三菱维修 | |
5 | 10104 | 美孚 | 60 | 31500 | 菲亚特维修 | |
6 | 10105 | 加德士 | 61 | 31501 | 阿尔法-罗密欧维修 | |
7 | 10107 | 东方 | 62 | 31600 | 法拉利维修 | |
8 | 10108 | 中石油碧辟 | 63 | 31601 | 玛莎拉蒂维修 | |
9 | 10109 | 中石化碧辟 | 64 | 31700 | 现代维修 | |
10 | 10110 | 道达尔 | 65 | 31701 | 进口现代维修 | |
11 | 10111 | 埃索 | 66 | 31702 | 北京现代维修 | |
12 | 10112 | 中化道达尔 | 67 | 31800 | 起亚维修 | |
13 | 30000 | 汽车维修 | 68 | 31801 | 进口起亚维修 | |
14 | 30100 | 汽车综合维修 | 69 | 31802 | 东风悦达起亚维修 | |
15 | 30200 | 大众维修 | 70 | 31900 | 福特维修 | |
16 | 30201 | 上海大众维修 | 71 | 31902 | 马自达维修 | |
17 | 30202 | 一汽大众维修 | 72 | 31903 | 林肯维修 | |
18 | 30203 | 斯柯达维修 | 73 | 31904 | 水星维修 | |
19 | 30204 | 进口大众维修 | 74 | 32000 | 捷豹维修 | |
20 | 30205 | 宾利维修 | 75 | 32100 | 路虎维修 | |
21 | 30206 | 兰博基尼维修 | 76 | 32200 | 保时捷维修 | |
22 | 30300 | 本田维修 | 77 | 32300 | 东风维修 | |
23 | 30301 | 广汽本田维修 | 78 | 32400 | 吉利维修 | |
24 | 30302 | 东风本田维修 | 79 | 32401 | 沃尔沃维修 | |
25 | 30303 | 本田讴歌维修 | 80 | 32500 | 奇瑞维修 | |
26 | 30400 | 奥迪维修 | 81 | 32600 | 克莱斯勒维修 | |
27 | 30401 | 一汽大众奥迪维修 | 82 | 32601 | 吉普维修 | |
28 | 30500 | 通用维修 | 83 | 32602 | 道奇维修 | |
29 | 30501 | 凯迪拉克维修 | 84 | 32700 | 荣威维修 | |
30 | 30502 | 别克维修 | 85 | 32800 | 名爵维修 | |
31 | 30503 | 雪佛兰维修 | 86 | 32900 | 江淮维修 | |
32 | 30504 | 欧宝维修 | 87 | 33000 | 红旗维修 | |
33 | 30505 | 萨博维修 | 88 | 33100 | 长安汽车维修 | |
34 | 30506 | 沃克斯豪尔维修 | 89 | 33200 | 海马汽车维修 | |
35 | 30507 | 土星维修 | 90 | 33300 | 北京汽车维修 | |
36 | 30508 | 大宇维修 | 91 | 33400 | 长城汽车维修 | |
37 | 30700 | 宝马维修 | 92 | 33500 | 纳智捷维修 | |
38 | 30701 | 宝马MINI维修 | 93 | 33600 | 广汽传祺维修 | |
39 | 30702 | 劳斯莱斯维修 | 94 | 39900 | 观致维修 | |
40 | 30800 | 日产维修 | 95 | 160301 | 中国银行ATM | |
41 | 30801 | 英菲尼迪维修 | 96 | 160302 | 中国工商银行ATM | |
42 | 30802 | 东风日产维修 | 97 | 160303 | 中国建设银行ATM | |
43 | 30803 | 郑州日产维修 | 98 | 160304 | 中国农业银行ATM | |
44 | 30900 | 雷诺维修 | 99 | 160305 | 交通银行ATM | |
45 | 31000 | 梅赛德斯-奔驰维修 | 100 | 160306 | 招商银行ATM | |
46 | 31004 | 迈巴赫维修 | 101 | 160316 | 北京银行ATM | |
47 | 31005 | 精灵维修 | 102 | 160318 | 农村商业银行ATM | |
48 | 31100 | 丰田维修 | 103 | 200300 | 公共厕所 | |
49 | 31101 | 一汽丰田维修 | ||||
50 | 31102 | 广汽丰田维修 | ||||
51 | 31103 | 雷克萨斯维修 | ||||
52 | 31104 | 大发维修 | ||||
53 | 31200 | 斯巴鲁维修 | ||||
54 | 31300 | 雪铁龙维修 | ||||
55 | 31301 | 东风标致维修 |
用户确定目的地并规划线路之后,用户可以搜索途经点, 并且把搜索结果添加到途经点。
1)在路线规划页面点击“途径”button,进入沿途搜索页面,点击搜索框,进入途径点搜索首页,可以进行途径点的搜索。
2) 搜索途径点首页及输入页里的历史关键字和历史目的地,同搜索首页、搜索输入页里的历史关键字和历史目的地记录一致。
3) 搜索途径点热词页配置同搜索热词页配置。
4)途径点搜索结果详情页,不可以收藏和查周边。
5)在搜索途经点首页(未输入状态)点击历史目的地可以直接添加途经点。
6)起点到沿途搜结果点的ETA时间:eta_to_via字段
com.autonavi.gbl.search.model.SearchAlongWayParam
String com.autonavi.gbl.search.model.SearchAlongWayParam.keyword
目前支持的关键字有:加油站,中石化,中石油,维修站,厕所,停车场,服务区,壳牌,美孚,充电站、加气站、美食;多个使用 ';' 连接
String com.autonavi.gbl.search.model.SearchAlongWayParam.category
category 支持 2位、4位、6位typecode,多个使用 | 连接,该字段仅在在线搜索时生效,不为空时keyword传值失效
String com.autonavi.gbl.search.model.SearchAlongWayParam.geoline
geoline 路线上的抽稀坐标点(至少两个),参考下方示例代码
int com.autonavi.gbl.search.model.SearchAlongWayParam.navi_type
navi_type 导航类型 1-骑行,4-步行,2-驾车,5-货车,9-摩托车
ArrayList<SearchRoadId> com.autonavi.gbl.search.model.SearchAlongWayParam.guideRoads
离线指定引导路径道路 ,离线搜索条件,离线搜索必填。
com.autonavi.gbl.search.model.SearchMode.SearchMode1
取值 | 描述 | 备注 |
SEARCH_MODE_ONLINE_ADVANCED | 在线优先 | 当在线搜索出现异常,会自动转离线搜索 |
SEARCH_MODE_OFFLINE_ADVANCED | 离线优先 | 若当前网络是wifi,会切到在线优先方式 |
SEARCH_MODE_ONLINE_ONLY | 仅在线 | |
SEARCH_MODE_OFFLINE_ONLY | 仅离线 |
taskid外部需自己保证全局唯一
com.autonavi.gbl.search.observer.IGSearchAlongWayObserver
com.autonavi.gbl.search.model.SearchAlongWayResult
pstResult关键信息如表格所示,更多返回信息可参考SearchAlongWayResult结构的成员描述。
int com.autonavi.gbl.search.model.SearchAlongWayResult.total
ArrayList<AlongWayPoi> com.autonavi.gbl.search.model.SearchAlongWayResult.pois
String com.autonavi.gbl.search.model.AlongWayPoi.id
String com.autonavi.gbl.search.model.AlongWayPoi.typecode
String com.autonavi.gbl.search.model.AlongWayPoi.name
Coord2DDouble com.autonavi.gbl.search.model.Alo
int
euRet为通用的返回错误码,可详见:
com.autonavi.gbl.util.errorcode.common.Service,
com.autonavi.gbl.util.errorcode.common.ThirdParty,
com.autonavi.gbl.util.errorcode.search.Online,
com.autonavi.gbl.util.errorcode.search.Offline 类型。
int com.autonavi.gbl.search.SearchService.alongWaySearch(SearchAlongWayParam param, IGSearchAlongWayObserver observer, @SearchMode.SearchMode1 int mode, int taskid)
备注:taskid为搜索发起请求的唯一任务id,由客户端分配,用于标识发起请求,客户端可根据此id调用中断接口,中断搜索请求,详见中断请求描述。
void com.autonavi.gbl.search.observer.IGSearchAlongWayObserver.onGetAlongWayResult(int taskid, int euRet, SearchAlongWayResult pstResult)
备注1:发起请求为异步接口,结果通过pstResult返回,返回状态参见euRet。
备注2:请注意observer的生命周期,搜索完成或者手动取消之前,请确保观察者不被释放。
说明:函数详情,请复制函数名称到在线API搜索。
// 建议定义成static类型\nstatic class SearchAlongWayObserver implements IGSearchAlongWayObserver {\n @Override\n public void onGetAlongWayResult(int taskid, int euRet, SearchAlongWayResult stResult) {\n Log.i(TAG, "onGetAlongWayResult: ");\n Log.i(TAG, " taskid = " + taskid);\n Log.i(TAG, " euRet = " + euRet);\n if (stResult != null) {\n Log.i(TAG, " result = " + stResult.result);\n Log.i(TAG, " message = " + stResult.message);\n Log.i(TAG, " version = " + stResult.version);\n Log.i(TAG, " timestamp = " + stResult.timestamp);\n\n if (stResult.pois != null && stResult.pois.length > 0) {\n Log.i(TAG, " address = " + stResult.pois[0].address);\n Log.i(TAG, " poiid = " + stResult.pois[0].id);\n Log.i(TAG, " name = " + stResult.pois[0].name);\n }\n }\n }\n}\n\n// 回调观察者,这边需要上层管理,不要每次发起搜索都new一个,定义成成员变量管理一个即可\nSearchAlongWayObserver searchAlongWayObserver = new SearchAlongWayObserver();
注意:观察者需要上层以内部类形式实现,建议定义成static类型,回调观察者的初始化需要上层管理,不要每次发起搜索都new一个,定义成成员变量管理一个即可。
public class SearchRequest\n{ \n /**< 沿途搜请求函数 */\n\tpublic void doAlongWaySearch()\n {\n // 1.构建参数\n /* 获取自车位所在经纬度 */\n Coord2DDouble carPos = getCarLocation();\n /* 通过经纬度获取自车位所在城市编码 */\n MapDataService mapDataService = ServiceMgr.getBLService(MapDataSingleServiceID); // 获取地图数据服务,com.autonavi.gbl.data.MapDataService\n int adCodeCarLoc = mapDataService.getAdcodeByLonLat(carPos.lon, arPos.lat);\n \n SearchAlongWayParam param = new SearchAlongWayParam();\n param.user_loc = carPos;\n param.keyword = "充电站"; // 替换为搜索关键字\n param.category = "";\n param.adcode = adCodeCarLoc;\n param.need_eta = true;\n \tparam.eta_flag = 0;\n \tparam.eta_type = 0;\n param.route_range = 1000;\n param.need_gasprice = false;\n param.specialSearch = 1;\n param.navi_scene = 2; // 1-行中,2-行前\n param.navi_type = 2; //导航类型 1-骑行,4-步行 2-驾车,5-货车,9-摩托车\n /* 获取途径点坐标 */\n\t\tparam.routepoints = getPathPoints(); \n /* 获取在线沿路径道路点信息字符串 */\n param.geoline = getAlongwaySearchGeoline();\n /* 获取离线指定引导路径道路 */\n param.guideRoads = getAlongwaySearchGuideRoads();\n /* 原路线linkid,透传给ETA */\n \t\tparam.linkid = getLinkId();\n /* 获取电动车参数配置信息 */\n param.elec = getRangeOnElecInfoConfig(); // 由上层自定义,非AutoSDK接口\n \n param.linkid_format = 0; //不压缩\n param.linkid_type = 3; //64位ID\n\n // 3. 生成唯一的任务id\n taskId = 1;\n \n // 发起沿途搜索\n\t\tint iret = SearchService.alongWaySearch(param, searchAlongWayObserver, SEARCH_MODE_ONLINE_ADVANCED, taskId);\n }\n \n\t/**< 获取自车位当前经纬度 */\n private Coord2DDouble getCarLocation()\n {\n Coord2DDouble carPos; // 自车位所在2D经度、纬度\n \n MapService mapService = ServiceMgr.getBLService(SingleServiceID.MapSingleServiceID);\n MapView mapView = mapService.getMapView(MapEngineID.MapEngineIdMain);\n \n BizControlService bizControlService = ServiceMgr.getBLService(SingleServiceID.BizControlSingleServiceID);\n \tBizCarControl bizCarControl = bizControlService.getBizCarControl(mapView);\t// 获取车标类图层控制 com.autonavi.gbl.layer.BizCarControl\n CarLoc carLoc = bizCarControl.getCarPosition();\n \n if (carLoc.vecPathMatchInfo.size() > 0)\n {\n \tcarPos.lon = vecPathMatchInfo.get(0).longitude;\n carPos.lat = vecPathMatchInfo.get(0).latitude;\n }\n \n return carPos;\n }\n \n /**< 获取算路起点,途经点,终点信息 */\n private String getPathPoints()\n {\n String strRoutepoints;\n // getRoutePoints() 由上层实现,用于获取沿途路径上的关键点。\n RoutePoints routePoints = getRoutePoints();\n \n double startLon = routePoints.mStartPoints.get(0).mPos.lon;\n double startLat = routePoints.mStartPoints.get(0).mPos.lat;\n String startPoint = "" + startLon + ";" + startLat;\n double endLon = routePoints.mEndPoints.get(0).mPos.lon;\n double endLat = routePoints.mEndPoints.get(0).mPos.lat;\n String endPoint = endLon + ";" + endLat;\n \n if (routePoints.mViaPoints.size() > 0)\n {\n double viaLon = routePoints.mViaPoints.get(0).mPos.lon;\n double viaLat = routePoints.mViaPoints.get(0).mPos.lat;\n String viaPoint = viaLon + ";" + viaLat;\n \n strRoutepoints = startPoint + ";" + viaPoint + ";" + endPoint;\n }\n else\n {\n strRoutepoints = startPoint + ";" + endPoint;\n }\n \n return strRoutepoints;\n }\n \n /**< 获取路线上坐标点 */\n private String getAlongwaySearchGeoline()\n {\n String geoline;\n \n // getSelectPath() 由上层实现,用于获取当前选中路径。\n // 提示:PathInfo对象通过算路结果监听回调IRouteResultObserver.onNewRoute获取\n PathInfo path = getSelectPath();\n if (null != path && path.isValid())\n {\n long maxDistance = path.getLength();\n \t// 获取抽稀形状点 buildRarefyPoint 参考引导章节 《5.3.5 路线数据访问》\n AlongWayProbeConfig config;//config已赋好初值,HMI无必要可以不修改\n ProbeNaviInfo info;//ProbeNaviInfo如果是行前,不需要 。如果是行中,根据当前实车位置具体赋值\n \tProbeResult probeRet = path.buildRarefyPoint(config, info);\n for (int i=0; i<probeRet.geolinePoints.size(); ++i)\n {\n geoline += probeRet.geolinePoints.get(i).lon;\n geoline += ";";\n geoline += probeRet.geolinePoints.get(i).lat;\n if (i == probeRet.geolinePoints.size()-1)\n {\n geoline += ";";\t/**< 字符串最后不加";"号 */\n }\n }\n }\n return geoline;\n }\n \n /**< 离线指定引导路径道路 ,离线搜索条件,离线搜索必填 */\n private ArrayList<SearchRoadId> getAlongwaySearchGuideRoads()\n {\n ArrayList<SearchRoadId> guideRoads = new ArrayList<>();\n // getSelectPath() 由上层实现,用于获取当前选中路径。\n // 提示:PathInfo对象通过算路结果监听回调IRouteResultObserver.onNewRoute获取\n PathInfo path = getSelectPath();\n if (null != path && path.isValid())\n {\n int segmentCount = path.getSegmentCount();\n for (int i=0; i<segmentCount; i++)\n {\n SegmentInfo segmentInfo = path.getSegmentInfo(i);\n \n if (null != segmentInfo)\n {\n if (segmentInfo.isValid())\n {\n long linkCount = segmentInfo.getLinkCount();\n for (long j=0; j<linkCount; j++)\n {\n LinkInfo linkInfo = segmentInfo.getLinkInfo(j);\n if (null != linkInfo)\n {\n \tif (linkInfo.isValid())\n {\n SearchRoadId roadId = new SearchRoadId();\n \t\troadId.roadId = linkInfo.getTPID();\n \t\troadId.tileId = linkInfo.getTileID();\n \t\troadId.urId = linkInfo.getURID();\n \t\tguideRoads.add(roadId);\n }\n linkInfo.delete()\n }\n \n } \n }\n segmentInfo.delete()\n } \n }\n }\n \n \n return guideRoads;\n }\n \n /**< 原路线linkid,透传给ETA */\n private String getLinkId()\n {\n String linkid;\n \n // getSelectPath() 由上层实现,用于获取当前选中路径。\n // 提示:PathInfo对象通过算路结果监听回调IRouteResultObserver.onNewRoute获取\n PathInfo path = getSelectPath();\n if (null != path && path.isValid())\n {\n ArrayList<Long> roadIds = path.getAlongRoadID(0, 0);\t// 获取沿途道路64位ID列表 \n int roadIdSize = roadIds.size();\n for (int i=0; i<roadIdSize; ++i)\n {\n if (0 == i)\n {\n linkid += roadIds.get(i);\n linkid += ";";\n }\n else if (roadIdSize - 1 == i)\n {\n long roadId = roadIds.get(i) - roadIds.get(i-1);\n linkid += roadId;\n }\n else\n {\n long roadId = roadIds.get(i) - roadIds.get(i-1);\n linkid += roadId;\n linkid += ";";\n }\n }\n }\n \n return linkid;\n }\n}
taskId = 1;\nSearchService.abort(taskId);