高德地图Api 搜索

快逃 快逃 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
写了高德地图的搜索
* 开始进行poi搜索
*/
protected void doSearchQuery() {
showProgressDialog();// 显示进度框
currentPage = 0;
query = new PoiSearch.Query(keyWord, "", "北京");// 第一个参数表示搜索字符串,第二个参数表示poi搜索类型,第三个参数表示poi搜索区域(空字符串代表全国)
query.setPageSize(10);// 设置每页最多返回多少条poiitem
query.setPageNum(currentPage);// 设置查第一页
query.setCityLimit(true);

poiSearch = new PoiSearch(this, query);
poiSearch.setOnPoiSearchListener(this);
poiSearch.searchPOIAsyn();
}

Marker lastCheckedMarker;
ArrayList<BitmapDescriptor> lastCheckedBitmapDescriptorList;
@Override
public void onPoiSearched(PoiResult result, int rCode) {
dissmissProgressDialog();// 隐藏对话框
if (rCode == 1000) {
if (result != null && result.getQuery() != null) {// 搜索poi的结果
if (result.getQuery().equals(query)) {// 是否是同一条
poiResult = result;

int resultPage=poiResult.getPageCount();
// 取得搜索到的poiitems有多少页
List<PoiItem> poiItems = poiResult.getPois();// 取得第一页的poiitem数据,页数从数字0开始
List<SuggestionCity> suggestionCities = poiResult
.getSearchSuggestionCitys();// 当搜索不到poiitem数据时,会返回含有搜索关键字的城市信息
aMap.clear();
if (poiItems != null && poiItems.size() > 0) {
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
for (int j = 0; j < Math.min(poiItems.size(), 10); j++) {
Log.d("result", "===result=="+poiItems.get(j).getTitle()+"=="+poiItems.get(j).getSnippet());
//1.通过图片名称字符串,获取对应的resId.
String iconName = "poi_marker_" + (j + 1);
int iconId = getResources().getIdentifier(iconName, "drawable", this.getPackageName());
MarkerOptions markerOptions = new MarkerOptions().icon
(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher));
markerOptions.position(new LatLng(poiItems.get(j).getLatLonPoint().getLatitude(),
poiItems.get(j)
.getLatLonPoint().getLongitude()));
markerOptions.title(poiItems.get(j).getTitle());
markerOptions.snippet(poiItems.get(j).getSnippet());
Marker marker = aMap.addMarker(markerOptions);
//为了POI填充整个地图区域
boundsBuilder.include(new LatLng(poiItems.get(j).getLatLonPoint().getLatitude(),
poiItems.get(j)
.getLatLonPoint().getLongitude()));
// if (j == 0) {
// lastCheckedMarker = marker;
// lastCheckedBitmapDescriptorList = lastCheckedMarker.getIcons();
// ArrayList<BitmapDescriptor> bitmapDescriptorArrayList = new ArrayList<>();
// bitmapDescriptorArrayList.add(BitmapDescriptorFactory.fromResource
// (R.drawable.ic_launcher));
// marker.setIcons(bitmapDescriptorArrayList);
// }
}
LatLngBounds bounds = boundsBuilder.build();
aMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 10));
} else if (suggestionCities != null
&& suggestionCities.size() > 0) {
showSuggestCity(suggestionCities);
} else {
Toast.makeText(this, "没有结果", Toast.LENGTH_SHORT).show();
}
}
} else {
Toast.makeText(this, "没有结果", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(this, ""+rCode, Toast.LENGTH_SHORT).show();
}

}
最后结果可以搜索,但是如果输入 例如 国展(地铁)15号线。搜索结果有很多,不是唯一的,是包含的。 但是如果是高德的app搜索就是唯一的。谁知道哪里控制这个?
...全文

相关推荐

API高德地图搜索选择地址实例.zip

API高德地图搜索选择地址实例,API高德地图搜索选择地址实例

billhepeng

高德地图API应用:地址搜索与选择实战教程

首先,访问高德开放平台官方网站,点击“立即注册”,按提示完成邮箱验证、设置密码等步骤。注册成功后,登录账号,进入控制台。控件是地图上用于实现特定功能的组件,如缩放控件、比例尺控件等。高德地图API允许开发者添加或自定义控件,以提供更好的用户体验。以下代码展示了如何添加一个比例尺控件:此外,还可以通过设置控件属性来自定义控件,例如更改控件的位置、显示或隐藏等。在本章节中,我们详细讨论了地图初始化的方法,包括创建和配置地图容器,以及如何根据特定需求定制化地图展示。

Lucy-Fintech社区

高德地图API拾取坐标并赋值,可通过搜索框进行搜索获取

高德地图API,拾取坐标,可通过点击地图获取,也可以通过搜索框进行搜索获取,带点标记

储备食物的小松鼠

基于高德地图API进行全国范围POI数据采集的Python爬虫程序_高德地图API调用_POI兴趣点搜索_关键词自定义设置_全国行政区划覆盖_数据爬取与存储_异常处理与日志记录_超.zip

基于高德地图API进行全国范围POI数据采集的Python爬虫程序_高德地图API调用_POI兴趣点搜索_关键词自定义设置_全国行政区划覆盖_数据爬取与存储_异常处理与日志记录_超.zip

zzq678912345

高德地图实现定位 获取周边 拖动 搜索

集成高德地图实现定位 获取周边信息 拖动地图更新周边信息 搜索更新信息

Man Up技术服务支持
评论
收藏 已收藏
分享
返回顶部
快逃
Android 80,490 成员 91,371 内容