{"version":"0.1.0","code":"0000","result":true,"message":"处理成功","errdetail":"","timestamp":1671508883847,"data":{"id":71712176,"title":"7.9 详细信息搜索","slug":"spwwi5","format":"lake","bookId":26046811,"body":null,"body_draft":null,"body_html":"
详细信息搜索用于获取POI点的详细信息,包括:名称、地址、城市位置等信息,该接口目前使用较少,基本使用关键字搜索中的ID搜索(IDQ)替代。
com.autonavi.gbl.search.model.SearchDetailInfoParam
String com.autonavi.gbl.search.model.SearchDetailInfoParam.id
Coord2DDouble com.autonavi.gbl.search.model.SearchDetailInfoParam.user_loc
String com.autonavi.gbl.search.model.SearchDetailInfoParam.poi_name
Coord2DDouble com.autonavi.gbl.search.model.SearchDetailInfoParam.poi_loc
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.IGSearchDetailInfoObserver
com.autonavi.gbl.search.model.SearchDetailInfoResult
pstResult关键信息如表格所示,更多返回信息可参考SearchDetailInfoResult结构的成员描述。
int com.autonavi.gbl.search.model.SearchDetailInfoResult.total
ArrayList<DetailPoi> com.autonavi.gbl.search.model.SearchDetailInfoResult.pois
String com.autonavi.gbl.search.model.DetailPoi.pguid
String com.autonavi.gbl.search.model.DetailPoi.name
Coord2DDouble com.autonavi.gbl.search.model.DetailPoi.point
String com.autonavi.gbl.search.model.DetailPoi.address
DetailBaseInfo com.autonavi.gbl.search.model.DetailPoi.baseinfo
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.detailInfoSearch(SearchDetailInfoParam param, IGSearchDetailInfoObserver observer, @SearchMode.SearchMode1 int mode, int taskid)
备注:taskid为搜索发起请求的唯一任务id,由客户端分配,用于标识发起请求,客户端可根据此id调用中断接口,中断搜索请求,详见中断请求描述。
void com.autonavi.gbl.search.observer.IGSearchDetailInfoObserver.onGetDetailInfoResult(int taskid, int euRet, SearchDetailInfoResult pstResult)
备注1:发起请求为异步接口,结果通过pstResult返回,返回状态参见euRet。
备注2:请注意observer的生命周期,搜索完成或者手动取消之前,请确保观察者不被释放。
说明:函数详情,请复制函数名称到在线API搜索。
// 建议定义成static类型\nstatic class SearchDetailInfoObserver implements IGSearchDetailInfoObserver {\n @Override\n public void onGetDetailInfoResult(int taskid, int euRet, SearchDetailInfoResult stResult) {\n Log.i(TAG, "onGetDetailInfoResult: ");\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, " pguid = " + stResult.pois[0].pguid);\n Log.i(TAG, " name = " + stResult.pois[0].name);\n }\n }\n }\n}\n\n// 回调观察者,这边需要上层管理,不要每次发起搜索都new一个,定义成成员变量管理一个即可\nSearchDetailInfoObserver searchDetailInfoObserver = new SearchDetailInfoObserver();
注意:观察者需要上层以内部类形式实现,建议定义成static类型,回调观察者的初始化需要上层管理,不要每次发起搜索都new一个,定义成成员变量管理一个即可。
public class SearchRequest\n{\n public void doDetailInfoSearch()\n {\n // 1. 构建搜索参数\n SearchDetailInfoParam param = new SearchDetailInfoParam();\n param.id = "B025003X94";\n param.user_loc = getCarLocation();\n param.poi_loc.lat = 24.436341;\n param.poi_loc.lon = 118.102555;\n param.poi_name = "厦门大学思明校区";\n\n // 2. 生成唯一的任务id\n taskId = 1;\n\n // 发起逆地理信息搜索\n int iret = SearchService.detailInfoSearch(param, searchNearestObserver, SEARCH_MODE_ONLINE_ADVANCED, taskId);\n }\n \n /**< 获取自车位当前经纬度 */\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 BizCarControl bizCarControl = bizControlService.getBizCarControl(mapView); // 获取车标类图层控制 com.autonavi.gbl.layer.BizCarControl\n CarLoc carLoc = bizCarControl.getCarPosition();\n \n if (carLoc.vecPathMatchInfo.size() > 0)\n {\n carPos.lon = vecPathMatchInfo.get(0).longitude;\n carPos.lat = vecPathMatchInfo.get(0).latitude;\n }\n \n return carPos;\n }\n}
taskId = 1;\nSearchService.abort(taskId);