android POI搜索,附近搜索,周边搜索定位介绍
POI搜索有三种方式。依据范围和检索词发起范围检索poiSearchInbounds。城市poi检索poiSearchInCity,周边检索poiSearchNearBy。
下以周边检索为例介绍怎样进行检索并显示覆盖物PoiOverlay:
public int poiSearchNearBy(java.lang.String key, title=Android%E5%B9%B3%E5%8F%B0/%E7%B1%BB%E5%8F%82%E8%80%83/GeoPoint" title="Android平台/类參考/GeoPoint" style="color:rgb(38,121,186); text-decoration:none">GeoPoint
int radius)
- 依据中心点、半径与检索词发起周边检索.
- 异步函数,返回结果在MKSearchListener里的onGetPoiResult方法通知
- 參数:
- key - 关键词
- pt - 中心点地理坐标
- radius - 半径。单位:米
- 返回:
- 成功返回0,否则返回-1
Demo: 检索天安门周边5000米之内的KFC餐厅
- mMKSearch.poiSearchNearBy("KFC", new GeoPoint((int) (39.915 * 1E6), (int) (116.404 * 1E6)), 5000);

- public void onGetPoiResult(MKPoiResult result, int type, int iError) {
- if (result == null) {
- return;
- }
- PoiOverlay poioverlay = new PoiOverlay(MyMapActivity.this, mMapView);
- poioverlay.setData(result.getAllPoi());
- mMapView.getOverlays().add(poioverlay);
- }
- package xiaosi.baiduMap;
- import android.os.Bundle;
- import com.baidu.mapapi.BMapManager;
- import com.baidu.mapapi.GeoPoint;
- import com.baidu.mapapi.MKAddrInfo;
- import com.baidu.mapapi.MKDrivingRouteResult;
- import com.baidu.mapapi.MKPoiResult;
- import com.baidu.mapapi.MKSearch;
- import com.baidu.mapapi.MKSearchListener;
- import com.baidu.mapapi.MKTransitRouteResult;
- import com.baidu.mapapi.MKWalkingRouteResult;
- import com.baidu.mapapi.MapActivity;
- import com.baidu.mapapi.MapController;
- import com.baidu.mapapi.MapView;
- import com.baidu.mapapi.PoiOverlay;
- public class BaiduMapActivity extends MapActivity
- {
- /** Called when the activity is first created. */
- private BMapManager mapManager = null;
- private String key = "1B79478DA01F7800AEA8602517A6D89B38151105";
- private MapView mapView = null;
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- mapManager = new BMapManager(getApplication());
- mapManager.init(key, null);
- super.initMapActivity(mapManager);
- mapView = (MapView) findViewById(R.id.mapsView);
- mapView.setBuiltInZoomControls(true); // 设置启用内置的缩放控件
- MapController mapController = mapView.getController(); // 得到mMapView的控制权,能够用它控制和驱动平移和缩放
- mapController.setZoom(12); // 设置地图zoom级别
- MKSearch mKSearch = new MKSearch();
- mKSearch.init(mapManager, new MySearchListener());// 注意。MKSearchListener仅仅支持一个。以最后一次设置为准
- mKSearch.poiSearchNearBy("KFC", new GeoPoint((int) (39.915 * 1E6),
- (int) (116.404 * 1E6)), 5000);
- }
- public class MySearchListener implements MKSearchListener
- {
- public void onGetAddrResult(MKAddrInfo arg0, int arg1)
- {}
- public void onGetDrivingRouteResult(MKDrivingRouteResult arg0, int arg1)
- {}
- public void onGetPoiResult(MKPoiResult arg0, int arg1, int arg2)
- {
- if (arg0 == null) {
- return;
- }
- PoiOverlay poioverlay = new PoiOverlay(BaiduMapActivity.this, mapView);
- poioverlay.setData(arg0.getAllPoi());
- mapView.getOverlays().add(poioverlay);
- }
- public void onGetTransitRouteResult(MKTransitRouteResult arg0, int arg1)
- {}
- public void onGetWalkingRouteResult(MKWalkingRouteResult arg0, int arg1)
- {}
- }
- @Override
- protected boolean isRouteDisplayed()
- {
- return false;
- }
- @Override
- protected void onDestroy()
- {
- if (mapManager != null)
- {
- mapManager.destroy();
- mapManager = null;
- }
- super.onDestroy();
- }
- @Override
- protected void onPause()
- {
- if (mapManager != null)
- {
- mapManager.stop();
- }
- super.onPause();
- }
- @Override
- protected void onResume()
- {
- if (mapManager != null)
- {
- mapManager.start();
- }
- super.onResume();
- }
- }
android POI搜索,附近搜索,周边搜索定位介绍的更多相关文章
- Android必知必会-带列表的地图POI周边搜索
如果移动端访问不佳,请尝试–> Github版 2016-08-22 更新 注意:在 Activity 代码中的onPoiSearched(PoiResult result, int rCode ...
- 【微信公众平台开发】百度周边搜索接口php封装
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcWl2YW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/d ...
- ZT android -- 蓝牙 bluetooth (三)搜索蓝牙
android -- 蓝牙 bluetooth (三)搜索蓝牙 分类: Android的原生应用分析 2013-05-31 22:03 2192人阅读 评论(8) 收藏 举报 bluetooth蓝牙s ...
- 用google map实现周边搜索功能
项目要实现根据经纬度获取附近的建筑,由于项目在海外运营,谷歌地图首当其冲. 首先说明的是,该功能需要在服务端实现,也就是安卓的SDK不适用. api文档地址: https://developers.g ...
- 高德地图搜索功能以及清除搜索结果maker
第一次写文章,写得不好各位看官见谅~ (pσ_σ)P首先这是一个vue里面的项目,高德地图api是直接CDN进来的,所以使用了global来调用,默认已经初始化了一个地图,为了实现一个输入框搜索功能和 ...
- CMake库搜索函数居然不搜索LD_LIBRARY_PATH
摘要: 本文通过编译后运行找不到库文件的问题引入,首先分析了find_package(JNI)的工作流程,而后针对cmake不搜索LD_LIBRARY_PATH的问题,提出了一种通用的解决办法. 本文 ...
- [转载]SharePoint 2013搜索学习笔记之搜索构架简单概述
Sharepoint搜索引擎主要由6种组件构成,他们分别是爬网组件,内容处理组件,分析处理组件,索引组件,查询处理组件,搜索管理组件.可以将这6种组件分别部署到Sharepoint场内的多个服务器上, ...
- 点击搜索取消UISearchDisplayController的搜索状态
一般,我们用到UISearchDisplayController的时候,都是须要对一个数据源进行刷选,在UISearchDisplayController自带的tableView中展示出来,然后点击退 ...
- lucene全文搜索之四:创建索引搜索器、6种文档搜索器实现以及搜索结果分析(结合IKAnalyzer分词器的搜索器)基于lucene5.5.3
前言: 前面几章已经很详细的讲解了如何创建索引器对索引进行增删查(没有更新操作).如何管理索引目录以及如何使用分词器,上一章讲解了如何生成索引字段和创建索引文档,并把创建的索引文档保存到索引目录,到这 ...
随机推荐
- mysql数据库比较,各数据库不同之处
和mysql数据库比较,各数据库不同之处: Oracle数据库:字段类型不同 postgresql数据库:show tables不同; SQL语句需要前面加上 模式名 Mongodb数据库:文档存储, ...
- typescript知识教程
https://ts.xcatliu.com/basics/type-of-function.html
- PHP13 会话控制
学习要点 会话控制使用的意义 用户跟踪方式 Cookie的设置.读取以及删除 Session的设置.读取以及删除 自定义session处理方式 会话控制 什么是会话控制 实现服务器跟踪同一个客户端的连 ...
- vs 2012安装ASP.NET MVC5
VS2012能使用MVC5开发,但VS2012不自带MVC5,需要安装“用于 Visual Studio 2012 的 ASP.NET 和 Web 工具 2013.1” 从下面提供的链接下载安装: h ...
- C# 如何正确删除List中的item
参考博客 https://blog.csdn.net/Le_Sam/article/details/75633737 https://www.cnblogs.com/hedianzhan/p/9130 ...
- UVa-1586-分子量
这是一道字符串的题目,我们直接对字符串进行解析,然后计算就可以了. 我是直接开了两个数组存入对应的值,没有进行判断,我们如果在if判断里面直接增加了i的值,最好先把对应的字符存起来,然后这样才不容易出 ...
- layui二次封装
最近一直用layui进行页面的重构,这个框架十分适合我们后台人员开发.简单易用,但是layui本身不支持双向绑定,所以很多情况下,我们在支持动态的控件加载时,需要反复刷新.这里我自己封装了一个comm ...
- bacula快速部署
快速部署: Server端:DD.SD.Monitor.Console均部署在Server上Client端:FD Server端部署:上传事先下载的源码包 tar xvf bacula-9.2.0.t ...
- nginx 集群
Nginx是什么? Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器.一直纳闷这个X是怎么来 ...
- memcached内存分配
Memcached默认情况下采用了名为Slab Allocator的机制分配.管理内存,最大单个存储对象大小为1M. page:分配给slab的最小内存空间,默认为1M,可以在启动时通过-l参数修改 ...