百度地图移动版API集成搜索服务包括:位置检索、周边检索、范围检索、公交检索、驾乘检索、步行检索,通过初始化MKSearch类,注册搜索结果的监听对象MKSearchListener,实现异步搜索服务。首先自定义MySearchListener实现MKSearchListener接口,通过不同的回调方法,获得搜索结果:
public class MySearchListener implements MKSearchListener { @Override public void onGetAddrResult(MKAddrInfo result, int iError) { } @Override public void onGetDrivingRouteResult(MKDrivingRouteResult result, int iError) { } @Override public void onGetPoiResult(MKPoiResult result, int type, int iError) { } @Override public void onGetTransitRouteResult(MKTransitRouteResult result, int iError) { } @Override public void onGetWalkingRouteResult(MKWalkingRouteResult result, int iError) { } }
然后初始化MKSearch类:
MKSearch mKSearch = new MKSearch(); mKSearch.init(mapManager, new MySearchListener());// 注意,MKSearchListener只支持一个,以最后一次设置为准
搜索服务用到的知识:类MKSearch
用于位置检索、周边检索、范围检索、公交检索、驾乘检索、步行检索
字段摘要
类型 | 名称 |
---|---|
static int | EBUS_NO_SUBWAY
|
static int | EBUS_TIME_FIRST
|
static int | EBUS_TRANSFER_FIRST
|
static int | EBUS_WALK_FIRST
|
static int | ECAR_DIS_FIRST
|
static int | ECAR_FEE_FIRST
|
static int | ECAR_TIME_FIRST
|
static int | TYPE_AREA_POI_LIST
|
static int | TYPE_CITY_LIST
|
static int | TYPE_POI_LIST
|
static int | TYPE_AREA_MULTI_POI_LIST
|
构造方法摘要
方法 |
---|
MKSearch()
|
方法摘要
返回类型 | 方法 |
---|---|
int | drivingSearch(java.lang.String startCity,MKPlanNodestart, java.lang.String endCity,MKPlanNodeend)
|
static int | getPoiPageCapacity()
|
int | goToPoiPage(int num)
|
boolean | init(BMapManagerbmapMan,MKSearchListenerlistener)
|
int | poiSearchInbounds(java.lang.String key,GeoPointptLB,GeoPointptRT)
|
int | poiMultiSearchInbounds(java.lang.String key,GeoPointptLB,GeoPointptRT)
|
int | poiSearchInCity(java.lang.String city, java.lang.String key)
|
int | poiSearchNearBy(java.lang.String key,GeoPointpt, int radius)
|
int | poiMultiSearchNearBy(java.lang.String key,GeoPointpt, int radius)
|
int | reverseGeocode(GeoPointpt)
|
int | geocode(java.lang.String strAddr, java.lang.String city)
|
int | setDrivingPolicy(int policy)
|
static void | setPoiPageCapacity(int num)
|
int | setTransitPolicy(int policy)
|
int | transitSearch(java.lang.String city,MKPlanNodestart,MKPlanNodeend)
|
int | walkingSearch(java.lang.String startCity,MKPlanNodestart, java.lang.String endCity,MKPlanNodeend)
|