公司企业",
result.getRegeocodeAddress().getCityCode());
mPoiQuery.setPageSize(10);// 设置每页最多返回多少条poiitem
mPoiQuery.setPageNum(0);//设置查第一页
PoiSearch poiSearch = new PoiSearch(this, mPoiQuery);
poiSearch.setOnPoiSearchListener(this);//设置数据返回的监听器 (5)
//设置周边搜索的中心点以及区域
poiSearch.setBound(new PoiSearch.SearchBound(mCurrentPoint, 1500, true));
poiSearch.searchPOIAsyn();//开始搜索
} else {
ToastUtil.show(mContext, R.string.no_result);
}
} else {
ToastUtil.show(mContexts, rCode);
}
}
//----------------地址编码回调:地址->坐标
@Override
public void onGeocodeSearched(GeocodeResult geocodeResult, int rCode) {
}
我们在这儿进行了poi周边搜索操作,回调方法
@Override
public void onPoiSearched(PoiResult result, int rcode) {
if (rcode == 0) {
if (result != null && result.getQuery() != null) {// 搜索poi的结果
if (result.getQuery().equals(query)) {// 是否是同一条
poiItems = poiResult.getPois();// 取得第一页的poiitem数据,页数从数字0开始
// 当搜索不到poiitem数据时,会返回含有搜索关键字的城市信息
List suggestionCities = poiResult
.getSearchSuggestionCitys();
/**
* listviw具体操作逻辑
*/
}
} else if (suggestionCities != null
&& suggestionCities.size() > 0) {
showSuggestCity(suggestionCities);
}else {
ToastUtil.show(mContexts, "对不起,没有搜索到相关数据!");
}
}
}
@Override
public void onPoiItemSearched(PoiItem poiitem, int rcode) {
}
/**
* poi没有搜索到数据,返回一些推荐城市的信息
*/
private void showSuggestCity(List cities) {
String infomation = "推荐城市\n";
for (int i = 0; i < cities.size(); i++) {
infomation += "城市名称:" + cities.get(i).getCityName() + "城市区号:"
+ cities.get(i).getCityCode() + "城市编码:"
+ cities.get(i).getAdCode() + "\n";
}
ToastUtil.show(this, infomation);
}
类似的含关键字的poi搜索也是类似的:
// 第一个参数表示搜索字符串,第二个参数表示poi搜索类型,第三个参数表示poi搜索区域(空字符串代表全国)
mPoiQuery = new PoiSearch.Query(key, "", cityCode);
mPoiSearch = new PoiSearch(this, mPoiQuery);
mPoiQuery.setPageSize(15);// 设置每页最多返回多少条poiitem
mPoiQuery.setPageNum(0);//设置查第一页
mPoiSearch.setOnPoiSearchListener(this);
// 设置搜索区域为以lp点为圆心,其周围5000米范围
LatLonPoint lp=new LatLonPoint(latitude,longitude);
mPoiSearch.setBound(new PoiSearch.SearchBound(lp, 5000, true));
mPoiSearch.searchPOIAsyn();//开始搜索
最后还有一个知识点就是我们点击item的时候地图自动去移动的实现,其实就是aMap.moveCamera方法去实现的,它会自动调用onCameraChangeFinish方法走的流程还是和我们手动拖动地图一样的。
复制代码 代码如下:
aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(poiItem.getLatLonPoint().getLatitude(), poiItem.getLatLonPoint().getLongitude()), 20));
微信支持多种语言,支持Wi-Fi无线局域网、2G,3G和4G移动数据网络,iOS版,Android版、Windows Phone版、Blackberry版、诺基亚S40版、S60V3和S60V5版
。