PoiSearch mPoiSearch = PoiSearch.newInstance(); OnGetPoiSearchResultListener poiListener = new OnGetPoiSearchResultListener(){ public void onGetPoiResult(PoiResult result){ if (result == null || result.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) { Toast.makeText(getApplicationContext(), "检索失败", Toast.LENGTH_LONG).show(); return; } if (result.error == SearchResult.ERRORNO.NO_ERROR) { mBaiduMap.clear(); ListIterator<PoiInfo> it=result.getAllPoi().listIterator(); int count=0; while(it.hasNext()){ Uid[count]=it.next(); count++; } } //获取POI检索结果 } public void onGetPoiDetailResult(PoiDetailResult result){ //获取Place详情页检索结果 } }; mPoiSearch.setOnGetPoiSearchResultListener(poiListener); /*mPoiSearch.searchInCity((new PoiCitySearchOption()) .city("北京") .keyword("公交") .pageNum(20));*/ mPoiSearch.searchInCity((new PoiCitySearchOption()) .city(Present_location.my_present_location.getCity()) .keyword("23路") .pageNum(10)); BusLineSearch mBusLineSearch = BusLineSearch.newInstance(); OnGetBusLineSearchResultListener busListener = new OnGetBusLineSearchResultListener() { @Override public void onGetBusLineResult(BusLineResult result) { // TODO Auto-generated method stub if (result == null || result.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) { Toast.makeText(getApplicationContext(), "附近无公交车车站", Toast.LENGTH_LONG).show(); return; } if (result.error == SearchResult.ERRORNO.NO_ERROR) { mBaiduMap.clear(); // 创建PoiOverlay MyBusLineOverlay overlay = new MyBusLineOverlay( mBaiduMap); // 设置overlay可以处理标注点击事件 mBaiduMap.setOnMarkerClickListener(overlay); // 设置PoiOverlay数据 overlay.setData(result); // 添加PoiOverlay到地图中 overlay.addToMap(); overlay.zoomToSpan(); return; } // 获取POI检索结果 } }; mBusLineSearch.setOnGetBusLineSearchResultListener(busListener); mBusLineSearch.searchBusLine(new BusLineSearchOption() .city(Present_location.my_present_location.getCity()) .uid(Uid[0].uid));
用的poi搜索附近线路,站点什么的条目很少。有没有做过这个的啊