Android 百度地图POI搜索功能实例代码

2019-12-10 19:10:12刘景俊

具体来说,即PoiSearch类的SearchInCity(PoiCitySearchOption) 发起检索时返回的结果增加门址类数据。PoiResult中新增了GetAllAddr()获取门址类列表,当isHasAddrInfo() 返回true时,除了原poi列表外,还包含门址结果。

Android 百度地图POI搜索功能实例代码

POI详情检索是指根据POI的ID信息,检索该兴趣点的详情。

Android 百度地图POI搜索功能实例代码

在线建议查询是指根据关键词查询在线建议词。为了帮助开发者实现检索出来的关键词快速定位到地图上,SDK自3.5.0版本起,开放了检索结果的经纬度信息及对应POI点的UID信息。

注意:

a. 在线建议检索的本质是根据部分关键是检索出来可能的完整关键词名称,如果需要这些关键词对应的POI的具体信息,请使用POI检索来完成;

b. 在线检索结果的第一条可能存在没有经纬度信息的情况,该条结果为文字联想出来的关键词结果,并不对应任何确切POI点。例如输入“肯”,第一条结果为“肯德基”,这条结果是一个泛指的名称,不会带有经纬度等信息。

二、运行截图

简介:介绍关键词查询、suggestion查询和查看餐饮类Place详情页功能

详述:

(1)点击某些关键词查询后的结果(如“餐厅”)可跳转到Place详情页;

(2)提供suggestion查询进行联想查询,例如输入“天安门”则会弹出联想查询的列表;

本示例运行截图如下:

Android 百度地图POI搜索功能实例代码

三、设计步骤

1、添加demo12_poisearch.xml文件

在layout文件夹下添加该文件,然后将代码改为下面的内容:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://www.easck.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://www.easck.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="在" >
</TextView>
<EditText
android:id="@+id/city"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="北京" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="市内找" >
</TextView>
<AutoCompleteTextView
android:id="@+id/searchkey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.88"
android:text="餐厅" />
</LinearLayout>
<LinearLayout
xmlns:android="http://www.easck.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:orientation="horizontal" >
<Button
android:id="@+id/search"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="12"
android:background="@drawable/button_style"
android:padding="10dip"
android:text="开始" />
<Button
android:id="@+id/map_next_data"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="12"
android:background="@drawable/button_style"
android:padding="10dip"
android:text="下一组数据" />
</LinearLayout>
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.baidu.mapapi.map.TextureMapFragment" />
</LinearLayout>