高德+关键字搜索+java_利用高德地图关键字检索POI-实现仿微信发朋友圈搜索附近位置...

本文介绍了如何使用高德地图API在Java项目中实现关键字搜索POI功能,通过创建布局、设置监听、创建适配器等步骤,展示了如何在Android应用中搜索并显示附近的地点信息。
摘要由CSDN通过智能技术生成

前言

由于项目中需要实现搜索附近位置作为收获地址,所以采用了高德地图的关键字检索POI来实现。官方Demo看了很复杂,估计很多人都不想看。但是看了我写的Demo你就会觉得So Easy啦!

先上效果图

363a8badb5eb

高德提供了千万级别的 POI(Point of Interest,兴趣点)。在地图表达中,一个 POI 可代表一栋大厦、一家商铺、一处景点等等。通过POI搜索,完成找餐馆、找景点、找厕所等等的功能。地图 SDK 的搜索功能提供多种获取 POI 数据的接口,下面说的是根据关键字检索POI

1,要实现关键字搜索POI,当然要先集成高德地图到你的项目中去

2,下面来看实现关键字搜索POI的具体代码

1,创建activity_poi_keyword_search.xml布局文件,如下:

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

android:id="@+id/et_keyword"

android:layout_width="match_parent"

android:layout_height="50dp"

android:background="@color/white"

android:hint="请输入地址关键字搜索"

android:paddingLeft="8dp"

android:textColor="@color/deep_black"

android:textSize="14sp"

/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="@color/line_color"/>

android:id="@+id/recyclerView"

android:layout_width="match_parent"

android:layout_height="match_parent">

2,创建recyclerview的item布局item_poi_keyword_search.xml,如下:

android:id="@+id/ll_item_layout"

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:background="@color/white"

android:orientation="vertical"

>

android:layout_width="match_parent"

android:layout_height="0.5dp"

android:background="@color/line_color"/>

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:orientation="vertical"

android:paddingBottom="8dp"

android:paddingLeft="10dp"

android:paddingRight="10dp"

android:paddingTop="8dp">

android:id="@+id/tv_detailAddress"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_vertical"

android:text="世界之窗"

android:textColor="@color/deep_black"

android:textSize="16sp"/>

android:id="@+id/tv_content"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_vertical"

android:text="1号线"

android:textColor="@color/shallow_black"

android:textSize="16sp"/>

3,创建实体类PoiAddressBean,如下:

package com.alpha58.poidemo.bean;

import java.io.Serializable;

/**

* author Alpha58

* time 2017/2/25 10:48

* desc ${TODO}

*

* upDateAuthor $Author$

* upDate $Date$

* upDateDesc ${TODO}

*/

public class PoiAddressBean implements Serializable {

private String longitude;//经度

private String latitude;//纬度

private String text;//信息内容

public String detailAddress;//详细地址 (搜索的关键字)

public String province;//省

public String city;//城市

public String district;//区域(宝安区)

public PoiAddressBean(String l

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值