# 高德地图 **Repository Path**: wlh520/android-place-search-master ## Basic Information - **Project Name**: 高德地图 - **Description**: tip定位 搜索框 (去官网重新下代码) - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2019-09-25 - **Last Updated**: 2021-06-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # android-place-search 输入提示与poi关键字搜索示例 ## 前述 ## - [高德官网申请Key](http://lbs.amap.com/dev/#/). - 阅读 [地图SDK参考手册](http://a.amap.com/lbs/static/unzip/Android_Map_Doc/index.html). - 工程基于高德地图实现 ## 使用方法## ###1:配置搭建AndroidSDK工程### - [Android Studio工程搭建方法](http://lbs.amap.com/api/android-sdk/guide/creat-project/android-studio-creat-project/#add-jars). - [通过maven库引入SDK方法](http://lbsbbs.amap.com/forum.php?mod=viewthread&tid=18786). ## 扫一扫安装## ![Screenshot](https://github.com/amap-demo/android-place-search/raw/master/resource/download.png) ## 示例效果## - 输入提示展示 ![Screenshot](https://github.com/amap-demo/android-place-search/raw/master/resource/Screenshot.png) - POI搜索结果展示 ![Screenshot](https://github.com/amap-demo/android-place-search/raw/master/resource/ScreenshotPoiSearch.png) ## 核心类/接口 ## | 类 | 接口 | 说明 | 版本 | | -----|:-----:|:-----:|:-----:| |PoiSearch| searchPOIAsyn()|查询POI异步接口|V2.1.0| |Inputtips|requestInputtipsAsyn()|查询输入提示的异步接口|V2.0.2| ## 核心难点 ##  - 输入字符变化时开启输入提示 ```java /** * 输入字符变化时触发 * * @param newText * @return */ @Override public boolean onQueryTextChange(String newText) { if (!AMapUtil.IsEmptyOrNullString(newText)) { InputtipsQuery inputquery = new InputtipsQuery(newText, Constants.DEFAULT_CITY); Inputtips inputTips = new Inputtips(InputTipsActivity.this.getApplicationContext(), inputquery); inputTips.setInputtipsListener(this); inputTips.requestInputtipsAsyn(); } else { if (mIntipAdapter != null && mCurrentTipList != null) { mCurrentTipList.clear(); mIntipAdapter.notifyDataSetChanged(); } } return false; } ```   - 输入提示获取tips或者搜索关键词处理逻辑 ```java /** * 输入提示activity选择结果后的处理逻辑 * * @param requestCode * @param resultCode * @param data */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_CODE_INPUTTIPS && data != null) { mAMap.clear(); Tip tip = data.getParcelableExtra(Constants.EXTRA_TIP); if (tip.getPoiID() == null || tip.getPoiID().equals("")) { doSearchQuery(tip.getName()); } else { addTipMarker(tip); } mKeywordsTextView.setText(tip.getName()); if(!tip.getName().equals("")){ mCleanKeyWords.setVisibility(View.VISIBLE); } } else if (resultCode == RESULT_CODE_KEYWORDS && data != null) { mAMap.clear(); String keywords = data.getStringExtra(Constants.KEY_WORDS_NAME); if(keywords != null && !keywords.equals("")){ doSearchQuery(keywords); } mKeywordsTextView.setText(keywords); if(!keywords.equals("")){ mCleanKeyWords.setVisibility(View.VISIBLE); } } } ```