美文网首页
Android BaiduMapSug检索 即关键字匹配

Android BaiduMapSug检索 即关键字匹配

作者: 懵懵懂懂_YOYO | 来源:发表于2020-11-16 10:19 被阅读0次

注意:Sug检索,city为必填项。

Sug检索默认不限制在city内,检索结果优先展示city内结果。

地点检索输入提示检索(Sug检索)

地点检索输入提示服务(也被称为POI热词建议检索、在线建议检索、Suggestion POI search),简称Sug检索,是指根据关键词查询在线建议词。为了帮助开发者实现检索出来的关键词快速定位到地图上,SDK开放了检索结果的经纬度信息及对应POI点的UID信息。

Sug检索示例

布局:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <LinearLayout android:layout_width="fill_parent" android:layout_height="50dip" android:background="@color/dkgray" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="在" android:textColor="@color/white" android:textStyle="bold" /> <EditText android:id="@+id/city" android:layout_width="wrap_content" android:layout_height="match_parent" android:text="北京" android:textColor="@color/white" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="市内找" android:textColor="@color/white" android:textStyle="bold" /> <AutoCompleteTextView android:id="@+id/searchkey" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0.88" android:hint="请输入联想关键字" android:textColor="@color/white" /> </LinearLayout> <ListView android:id="@+id/sug_list" android:layout_width="match_parent" android:layout_height="wrap_content" /></LinearLayout>

1.

// 初始化建议搜索模块,注册建议搜索事件监听

mSuggestionSearch = SuggestionSearch.newInstance();

mSuggestionSearch.setOnGetSuggestionResultListener(this);

2.

/**

* 获取在线建议搜索结果,得到requestSuggestion返回的搜索结果

*

* @param suggestionResult    Sug检索结果

*/

@Override

public void onGetSuggestionResult(SuggestionResult suggestionResult) {

if (suggestionResult ==null || suggestionResult.getAllSuggestions() ==null) {

return;

    }

List> suggest =new ArrayList<>();

    for (SuggestionResult.SuggestionInfo info : suggestionResult.getAllSuggestions()) {

if (info.getKey() !=null && info.getDistrict() !=null && info.getCity() !=null) {

HashMap map =new HashMap<>();

            map.put("key",info.getKey());

            map.put("city",info.getCity());

            map.put("dis",info.getDistrict());

            suggest.add(map);

        }

}

SimpleAdapter simpleAdapter =new SimpleAdapter(getApplicationContext(),

            suggest,

            R.layout.item_layout,

            new String[]{"key", "city","dis"},

            new int[]{R.id.sug_key, R.id.sug_city, R.id.sug_dis});

    mSugListView.setAdapter(simpleAdapter);

    simpleAdapter.notifyDataSetChanged();

}

3.

// 当输入关键字变化时,动态更新建议列表

mKeyWordsView.addTextChangedListener(new TextWatcher() {

@Override

    public void afterTextChanged(Editable arg0) {

}

@Override

    public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {

}

@Override

    public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {

if (cs.length() <=0) {

return;

        }

// 使用建议搜索服务获取建议列表,结果在onSuggestionResult()中更新

        mSuggestionSearch.requestSuggestion((new SuggestionSearchOption())

.keyword(cs.toString())// 关键字

                .city(mEditCity.getText().toString())); // 城市

    }

});

4.释放检索实例

@Override

protected void onDestroy() {

super.onDestroy();

    mSuggestionSearch.destroy();

}

参考:地点输入提示检索

代码截图:

相关文章

  • Android BaiduMapSug检索 即关键字匹配

    注意:Sug检索,city为必填项。Sug检索默认不限制在city内,检索结果优先展示city内结果。 地点检索输...

  • Android之EditText检索Listview,匹配关键字

    需求背景:在android 开发中,我们经常用EditText通过搜索关键字,来查询listview里面的内容,并...

  • Mysql全文检索

    一、概述MySQL全文检索是利用查询关键字和查询列内容之间的相关度进行检索,可以利用全文检索来提高匹配的速度。 二...

  • mysql的全文检索

    一、概述 MySQL全文检索是利用查询关键字和查询列内容之间的相关度进行检索,可以利用全文索引来提高匹配的速度。 ...

  • 一个适合非贪婪需求的JS正则思路

    这个正则 适用于 在一段字符串中 匹配 关键字A到某个关键字B的值,且可以多次匹配(即不贪婪匹配) 这里同理 可...

  • 知网的检索坑

    当我使用常规检索时: 检索结果较多,不是精准匹配。 当我使用高级检索时: 检索结果较少,是精准匹配。

  • MySQL 对数据进行检索,排序,操作符过滤

    检索数据 检索单个列 检索多个列 检索所有列 使用DISTINCT关键字 限制查询,LIMIT关键字 可用来实现分...

  • elasticsearch http postman 查询数据

    查询数据,默认显示10条 查询数据,可指定size,显示N条 关键字检索 关键字检索,&并且关系 关键字检索,or...

  • 检索类机器人

    固定领域: 开放领域: 检索匹配 检索类机器人的运行过程: 检索的技术:主要是基于专业上的知识 模式匹配: 匹配的...

  • Google搜索的PageRank算法

    joselynzhao·原文链接 背景和问题 搜索引擎工作流程 网页信息检索(录入关键字) 匹配搜索请求(在索引数...

网友评论

      本文标题:Android BaiduMapSug检索 即关键字匹配

      本文链接:https://www.haomeiwen.com/subject/fmdabktx.html