├── .gitignore ├── .idea └── misc.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── amap │ │ └── placesearch │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── amap │ │ │ └── placesearch │ │ │ ├── InputTipsActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── adapter │ │ │ └── InputTipsAdapter.java │ │ │ ├── overlay │ │ │ └── PoiOverlay.java │ │ │ └── util │ │ │ ├── Constants.java │ │ │ └── ToastUtil.java │ └── res │ │ ├── drawable │ │ ├── back.xml │ │ ├── start_uri.png │ │ ├── text_search.xml │ │ ├── text_search_default.9.png │ │ ├── text_search_pressed.9.png │ │ ├── text_search_selected.9.png │ │ └── title_background.9.png │ │ ├── layout │ │ ├── activity_input_tips.xml │ │ ├── activity_main.xml │ │ ├── adapter_inputtips.xml │ │ └── poikeywordsearch_uri.xml │ │ ├── menu │ │ └── options_menu.xml │ │ ├── mipmap-hdpi │ │ ├── ic_arrow_back.png │ │ ├── ic_close.png │ │ ├── ic_keyboard_voice.png │ │ ├── ic_launcher.png │ │ └── ic_search.png │ │ ├── mipmap-mdpi │ │ ├── ic_arrow_back.png │ │ ├── ic_close.png │ │ ├── ic_keyboard_voice.png │ │ ├── ic_launcher.png │ │ └── ic_search.png │ │ ├── mipmap-xhdpi │ │ ├── ic_arrow_back.png │ │ ├── ic_close.png │ │ ├── ic_keyboard_voice.png │ │ ├── ic_launcher.png │ │ └── ic_search.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_arrow_back.png │ │ ├── ic_close.png │ │ ├── ic_keyboard_voice.png │ │ ├── ic_launcher.png │ │ └── ic_search.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── amap │ └── placesearch │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── resource ├── Screenshot.png ├── ScreenshotPoiSearch.png ├── app-debug.apk └── download.png └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .idea/.name 10 | .idea/compiler.xml 11 | .idea/copyright/profiles_settings.xml 12 | .idea/encodings.xml 13 | .idea/gradle.xml 14 | .idea/modules.xml 15 | .idea/runConfigurations.xml 16 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 43 | 44 | 45 | 46 | 47 | 1.7 48 | 49 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # android-place-search 2 | 3 | 输入提示与poi关键字搜索示例 4 | 5 | ## 前述 ## 6 | - [高德官网申请Key](http://lbs.amap.com/dev/#/). 7 | - 阅读 8 | [地图SDK参考手册](http://a.amap.com/lbs/static/unzip/Android_Map_Doc/index.html). 9 | - 工程基于高德地图实现 10 | 11 | ## 使用方法## 12 | ###1:配置搭建AndroidSDK工程### 13 | - [Android Studio工程搭建方法](http://lbs.amap.com/api/android-sdk/guide/creat-project/android-studio-creat-project/#add-jars). 14 | - [通过maven库引入SDK方法](http://lbsbbs.amap.com/forum.php?mod=viewthread&tid=18786). 15 | 16 | ## 扫一扫安装## 17 | 18 | ![Screenshot](https://github.com/amap-demo/android-place-search/raw/master/resource/download.png) 19 | 20 | ## 示例效果## 21 | 22 | - 输入提示展示 23 | 24 | ![Screenshot](https://github.com/amap-demo/android-place-search/raw/master/resource/Screenshot.png) 25 | 26 | - POI搜索结果展示 27 | 28 | ![Screenshot](https://github.com/amap-demo/android-place-search/raw/master/resource/ScreenshotPoiSearch.png) 29 | 30 | ## 核心类/接口 ## 31 | | 类 | 接口 | 说明 | 版本 | 32 | | -----|:-----:|:-----:|:-----:| 33 | |PoiSearch| searchPOIAsyn()|查询POI异步接口|V2.1.0| 34 | |Inputtips|requestInputtipsAsyn()|查询输入提示的异步接口|V2.0.2| 35 | 36 | ## 核心难点 ## 37 |  - 输入字符变化时开启输入提示 38 | ```java 39 | /** 40 | * 输入字符变化时触发 41 | * 42 | * @param newText 43 | * @return 44 | */ 45 | @Override 46 | public boolean onQueryTextChange(String newText) { 47 | if (!AMapUtil.IsEmptyOrNullString(newText)) { 48 | InputtipsQuery inputquery = new InputtipsQuery(newText, Constants.DEFAULT_CITY); 49 | Inputtips inputTips = new Inputtips(InputTipsActivity.this.getApplicationContext(), inputquery); 50 | inputTips.setInputtipsListener(this); 51 | inputTips.requestInputtipsAsyn(); 52 | } else { 53 | if (mIntipAdapter != null && mCurrentTipList != null) { 54 | mCurrentTipList.clear(); 55 | mIntipAdapter.notifyDataSetChanged(); 56 | } 57 | } 58 | return false; 59 | } 60 | ``` 61 |   - 输入提示获取tips或者搜索关键词处理逻辑 62 | ```java 63 | /** 64 | * 输入提示activity选择结果后的处理逻辑 65 | * 66 | * @param requestCode 67 | * @param resultCode 68 | * @param data 69 | */ 70 | 71 | @Override 72 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 73 | super.onActivityResult(requestCode, resultCode, data); 74 | if (resultCode == RESULT_CODE_INPUTTIPS && data 75 | != null) { 76 | mAMap.clear(); 77 | Tip tip = data.getParcelableExtra(Constants.EXTRA_TIP); 78 | if (tip.getPoiID() == null || tip.getPoiID().equals("")) { 79 | doSearchQuery(tip.getName()); 80 | } else { 81 | addTipMarker(tip); 82 | } 83 | mKeywordsTextView.setText(tip.getName()); 84 | if(!tip.getName().equals("")){ 85 | mCleanKeyWords.setVisibility(View.VISIBLE); 86 | } 87 | } else if (resultCode == RESULT_CODE_KEYWORDS && data != null) { 88 | mAMap.clear(); 89 | String keywords = data.getStringExtra(Constants.KEY_WORDS_NAME); 90 | if(keywords != null && !keywords.equals("")){ 91 | doSearchQuery(keywords); 92 | } 93 | mKeywordsTextView.setText(keywords); 94 | if(!keywords.equals("")){ 95 | mCleanKeyWords.setVisibility(View.VISIBLE); 96 | } 97 | } 98 | } 99 | ``` 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion '25.0.0' 6 | 7 | defaultConfig { 8 | applicationId "com.amap.placesearch" 9 | minSdkVersion 14 10 | targetSdkVersion 26 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.2.1' 26 | compile 'com.amap.api:3dmap:latest.integration' 27 | compile 'com.amap.api:search:latest.integration' 28 | } 29 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/ligen/develope/android-sdk-macosx/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/amap/placesearch/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.amap.placesearch; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |   16 | 17 | 18 | 24 | 27 | 28 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/amap/placesearch/InputTipsActivity.java: -------------------------------------------------------------------------------- 1 | package com.amap.placesearch; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.widget.AdapterView; 8 | import android.widget.ImageView; 9 | import android.widget.ListView; 10 | import android.widget.AdapterView.OnItemClickListener; 11 | import android.support.v7.widget.SearchView; 12 | 13 | import com.amap.api.services.help.Inputtips; 14 | import com.amap.api.services.help.InputtipsQuery; 15 | import com.amap.api.services.help.Tip; 16 | import com.amap.placesearch.adapter.InputTipsAdapter; 17 | import com.amap.placesearch.util.Constants; 18 | import com.amap.placesearch.util.ToastUtil; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | public class InputTipsActivity extends Activity implements SearchView.OnQueryTextListener, Inputtips.InputtipsListener, OnItemClickListener, View.OnClickListener { 24 | private SearchView mSearchView;// 输入搜索关键字 25 | private ImageView mBack; 26 | private ListView mInputListView; 27 | private List mCurrentTipList; 28 | private InputTipsAdapter mIntipAdapter; 29 | 30 | @Override 31 | protected void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | setContentView(R.layout.activity_input_tips); 34 | initSearchView(); 35 | mInputListView = (ListView) findViewById(R.id.inputtip_list); 36 | mInputListView.setOnItemClickListener(this); 37 | mBack = (ImageView) findViewById(R.id.back); 38 | mBack.setOnClickListener(this); 39 | } 40 | 41 | private void initSearchView() { 42 | mSearchView = (SearchView) findViewById(R.id.keyWord); 43 | mSearchView.setOnQueryTextListener(this); 44 | //设置SearchView默认为展开显示 45 | mSearchView.setIconified(false); 46 | mSearchView.onActionViewExpanded(); 47 | mSearchView.setIconifiedByDefault(true); 48 | mSearchView.setSubmitButtonEnabled(false); 49 | } 50 | 51 | /** 52 | * 输入提示回调 53 | * 54 | * @param tipList 55 | * @param rCode 56 | */ 57 | @Override 58 | public void onGetInputtips(List tipList, int rCode) { 59 | if (rCode == 1000) {// 正确返回 60 | mCurrentTipList = tipList; 61 | List listString = new ArrayList(); 62 | for (int i = 0; i < tipList.size(); i++) { 63 | listString.add(tipList.get(i).getName()); 64 | } 65 | mIntipAdapter = new InputTipsAdapter( 66 | getApplicationContext(), 67 | mCurrentTipList); 68 | mInputListView.setAdapter(mIntipAdapter); 69 | mIntipAdapter.notifyDataSetChanged(); 70 | } else { 71 | ToastUtil.showerror(this, rCode); 72 | } 73 | 74 | } 75 | 76 | @Override 77 | public void onItemClick(AdapterView adapterView, View view, int i, long l) { 78 | if (mCurrentTipList != null) { 79 | Tip tip = (Tip) adapterView.getItemAtPosition(i); 80 | Intent intent = new Intent(); 81 | intent.putExtra(Constants.EXTRA_TIP, tip); 82 | setResult(MainActivity.RESULT_CODE_INPUTTIPS, intent); 83 | this.finish(); 84 | } 85 | } 86 | 87 | /** 88 | * 按下确认键触发,本例为键盘回车或搜索键 89 | * 90 | * @param query 91 | * @return 92 | */ 93 | @Override 94 | public boolean onQueryTextSubmit(String query) { 95 | Intent intent = new Intent(); 96 | intent.putExtra(Constants.KEY_WORDS_NAME, query); 97 | setResult(MainActivity.RESULT_CODE_KEYWORDS, intent); 98 | this.finish(); 99 | return false; 100 | } 101 | 102 | /** 103 | * 输入字符变化时触发 104 | * 105 | * @param newText 106 | * @return 107 | */ 108 | @Override 109 | public boolean onQueryTextChange(String newText) { 110 | if (!IsEmptyOrNullString(newText)) { 111 | InputtipsQuery inputquery = new InputtipsQuery(newText, Constants.DEFAULT_CITY); 112 | Inputtips inputTips = new Inputtips(InputTipsActivity.this.getApplicationContext(), inputquery); 113 | inputTips.setInputtipsListener(this); 114 | inputTips.requestInputtipsAsyn(); 115 | } else { 116 | if (mIntipAdapter != null && mCurrentTipList != null) { 117 | mCurrentTipList.clear(); 118 | mIntipAdapter.notifyDataSetChanged(); 119 | } 120 | } 121 | return false; 122 | } 123 | 124 | @Override 125 | public void onClick(View view) { 126 | if (view.getId() == R.id.back) { 127 | this.finish(); 128 | } 129 | } 130 | 131 | public static boolean IsEmptyOrNullString(String s) { 132 | return (s == null) || (s.trim().length() == 0); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /app/src/main/java/com/amap/placesearch/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.amap.placesearch; 2 | 3 | import android.app.ProgressDialog; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.support.v4.app.FragmentActivity; 7 | import android.view.View; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import com.amap.api.maps.AMap; 12 | import com.amap.api.maps.CameraUpdateFactory; 13 | import com.amap.api.maps.SupportMapFragment; 14 | import com.amap.api.maps.model.LatLng; 15 | import com.amap.api.maps.model.Marker; 16 | import com.amap.api.maps.model.MarkerOptions; 17 | import com.amap.api.maps.AMap.OnMarkerClickListener; 18 | import com.amap.api.maps.AMap.InfoWindowAdapter; 19 | import com.amap.api.services.core.LatLonPoint; 20 | import com.amap.api.services.help.Tip; 21 | import com.amap.api.services.poisearch.PoiSearch.OnPoiSearchListener; 22 | 23 | import android.view.View.OnClickListener; 24 | 25 | import com.amap.api.services.core.PoiItem; 26 | import com.amap.api.services.core.SuggestionCity; 27 | import com.amap.api.services.poisearch.PoiResult; 28 | import com.amap.api.services.poisearch.PoiSearch; 29 | import com.amap.placesearch.overlay.PoiOverlay; 30 | import com.amap.placesearch.util.Constants; 31 | import com.amap.placesearch.util.ToastUtil; 32 | 33 | import java.util.List; 34 | 35 | public class MainActivity extends FragmentActivity implements 36 | OnMarkerClickListener, InfoWindowAdapter, 37 | OnPoiSearchListener, OnClickListener { 38 | private AMap mAMap; 39 | private String mKeyWords = "";// 要输入的poi搜索关键字 40 | private ProgressDialog progDialog = null;// 搜索时进度条 41 | 42 | private PoiResult poiResult; // poi返回的结果 43 | private int currentPage = 1; 44 | private PoiSearch.Query query;// Poi查询条件类 45 | private PoiSearch poiSearch;// POI搜索 46 | private TextView mKeywordsTextView; 47 | private Marker mPoiMarker; 48 | private ImageView mCleanKeyWords; 49 | 50 | public static final int REQUEST_CODE = 100; 51 | public static final int RESULT_CODE_INPUTTIPS = 101; 52 | public static final int RESULT_CODE_KEYWORDS = 102; 53 | 54 | @Override 55 | protected void onCreate(Bundle savedInstanceState) { 56 | super.onCreate(savedInstanceState); 57 | setContentView(R.layout.activity_main); 58 | mCleanKeyWords = (ImageView)findViewById(R.id.clean_keywords); 59 | mCleanKeyWords.setOnClickListener(this); 60 | init(); 61 | mKeyWords = ""; 62 | } 63 | 64 | /** 65 | * 初始化AMap对象 66 | */ 67 | private void init() { 68 | if (mAMap == null) { 69 | mAMap = ((SupportMapFragment) this.getSupportFragmentManager() 70 | .findFragmentById(R.id.map)).getMap(); 71 | 72 | setUpMap(); 73 | } 74 | mKeywordsTextView = (TextView) findViewById(R.id.main_keywords); 75 | mKeywordsTextView.setOnClickListener(this); 76 | } 77 | 78 | /** 79 | * 设置页面监听 80 | */ 81 | private void setUpMap() { 82 | mAMap.setOnMarkerClickListener(this);// 添加点击marker监听事件 83 | mAMap.setInfoWindowAdapter(this);// 添加显示infowindow监听事件 84 | mAMap.getUiSettings().setRotateGesturesEnabled(false); 85 | } 86 | 87 | /** 88 | * 显示进度框 89 | */ 90 | private void showProgressDialog() { 91 | if (progDialog == null) 92 | progDialog = new ProgressDialog(this); 93 | progDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); 94 | progDialog.setIndeterminate(false); 95 | progDialog.setCancelable(false); 96 | progDialog.setMessage("正在搜索:\n" + mKeyWords); 97 | progDialog.show(); 98 | } 99 | 100 | /** 101 | * 隐藏进度框 102 | */ 103 | private void dissmissProgressDialog() { 104 | if (progDialog != null) { 105 | progDialog.dismiss(); 106 | } 107 | } 108 | 109 | /** 110 | * 开始进行poi搜索 111 | */ 112 | protected void doSearchQuery(String keywords) { 113 | showProgressDialog();// 显示进度框 114 | currentPage = 1; 115 | // 第一个参数表示搜索字符串,第二个参数表示poi搜索类型,第三个参数表示poi搜索区域(空字符串代表全国) 116 | query = new PoiSearch.Query(keywords, "", Constants.DEFAULT_CITY); 117 | // 设置每页最多返回多少条poiitem 118 | query.setPageSize(10); 119 | // 设置查第一页 120 | query.setPageNum(currentPage); 121 | 122 | poiSearch = new PoiSearch(this, query); 123 | poiSearch.setOnPoiSearchListener(this); 124 | poiSearch.searchPOIAsyn(); 125 | } 126 | 127 | @Override 128 | public boolean onMarkerClick(Marker marker) { 129 | marker.showInfoWindow(); 130 | return false; 131 | } 132 | 133 | @Override 134 | public View getInfoContents(Marker marker) { 135 | return null; 136 | } 137 | 138 | @Override 139 | public View getInfoWindow(final Marker marker) { 140 | View view = getLayoutInflater().inflate(R.layout.poikeywordsearch_uri, 141 | null); 142 | TextView title = (TextView) view.findViewById(R.id.title); 143 | title.setText(marker.getTitle()); 144 | 145 | TextView snippet = (TextView) view.findViewById(R.id.snippet); 146 | snippet.setText(marker.getSnippet()); 147 | return view; 148 | } 149 | 150 | /** 151 | * poi没有搜索到数据,返回一些推荐城市的信息 152 | */ 153 | private void showSuggestCity(List cities) { 154 | String infomation = "推荐城市\n"; 155 | for (int i = 0; i < cities.size(); i++) { 156 | infomation += "城市名称:" + cities.get(i).getCityName() + "城市区号:" 157 | + cities.get(i).getCityCode() + "城市编码:" 158 | + cities.get(i).getAdCode() + "\n"; 159 | } 160 | ToastUtil.show(MainActivity.this, infomation); 161 | 162 | } 163 | 164 | 165 | /** 166 | * POI信息查询回调方法 167 | */ 168 | @Override 169 | public void onPoiSearched(PoiResult result, int rCode) { 170 | dissmissProgressDialog();// 隐藏对话框 171 | if (rCode == 1000) { 172 | if (result != null && result.getQuery() != null) {// 搜索poi的结果 173 | if (result.getQuery().equals(query)) {// 是否是同一条 174 | poiResult = result; 175 | // 取得搜索到的poiitems有多少页 176 | List poiItems = poiResult.getPois();// 取得第一页的poiitem数据,页数从数字0开始 177 | List suggestionCities = poiResult 178 | .getSearchSuggestionCitys();// 当搜索不到poiitem数据时,会返回含有搜索关键字的城市信息 179 | 180 | if (poiItems != null && poiItems.size() > 0) { 181 | mAMap.clear();// 清理之前的图标 182 | PoiOverlay poiOverlay = new PoiOverlay(mAMap, poiItems); 183 | poiOverlay.removeFromMap(); 184 | poiOverlay.addToMap(); 185 | poiOverlay.zoomToSpan(); 186 | } else if (suggestionCities != null 187 | && suggestionCities.size() > 0) { 188 | showSuggestCity(suggestionCities); 189 | } else { 190 | ToastUtil.show(MainActivity.this, 191 | R.string.no_result); 192 | } 193 | } 194 | } else { 195 | ToastUtil.show(MainActivity.this, 196 | R.string.no_result); 197 | } 198 | } else { 199 | ToastUtil.showerror(this, rCode); 200 | } 201 | 202 | } 203 | 204 | @Override 205 | public void onPoiItemSearched(PoiItem item, int rCode) { 206 | // TODO Auto-generated method stub 207 | 208 | } 209 | 210 | /** 211 | * 输入提示activity选择结果后的处理逻辑 212 | * 213 | * @param requestCode 214 | * @param resultCode 215 | * @param data 216 | */ 217 | 218 | @Override 219 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 220 | super.onActivityResult(requestCode, resultCode, data); 221 | if (resultCode == RESULT_CODE_INPUTTIPS && data 222 | != null) { 223 | mAMap.clear(); 224 | Tip tip = data.getParcelableExtra(Constants.EXTRA_TIP); 225 | if (tip.getPoiID() == null || tip.getPoiID().equals("")) { 226 | doSearchQuery(tip.getName()); 227 | } else { 228 | addTipMarker(tip); 229 | } 230 | mKeywordsTextView.setText(tip.getName()); 231 | if(!tip.getName().equals("")){ 232 | mCleanKeyWords.setVisibility(View.VISIBLE); 233 | } 234 | } else if (resultCode == RESULT_CODE_KEYWORDS && data != null) { 235 | mAMap.clear(); 236 | String keywords = data.getStringExtra(Constants.KEY_WORDS_NAME); 237 | if(keywords != null && !keywords.equals("")){ 238 | doSearchQuery(keywords); 239 | } 240 | mKeywordsTextView.setText(keywords); 241 | if(!keywords.equals("")){ 242 | mCleanKeyWords.setVisibility(View.VISIBLE); 243 | } 244 | } 245 | } 246 | 247 | /** 248 | * 用marker展示输入提示list选中数据 249 | * 250 | * @param tip 251 | */ 252 | private void addTipMarker(Tip tip) { 253 | if (tip == null) { 254 | return; 255 | } 256 | mPoiMarker = mAMap.addMarker(new MarkerOptions()); 257 | LatLonPoint point = tip.getPoint(); 258 | if (point != null) { 259 | LatLng markerPosition = new LatLng(point.getLatitude(), point.getLongitude()); 260 | mPoiMarker.setPosition(markerPosition); 261 | mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(markerPosition, 17)); 262 | } 263 | mPoiMarker.setTitle(tip.getName()); 264 | mPoiMarker.setSnippet(tip.getAddress()); 265 | } 266 | 267 | /** 268 | * 点击事件回调方法 269 | */ 270 | @Override 271 | public void onClick(View v) { 272 | switch (v.getId()) { 273 | case R.id.main_keywords: 274 | Intent intent = new Intent(this, InputTipsActivity.class); 275 | startActivityForResult(intent, REQUEST_CODE); 276 | break; 277 | case R.id.clean_keywords: 278 | mKeywordsTextView.setText(""); 279 | mAMap.clear(); 280 | mCleanKeyWords.setVisibility(View.GONE); 281 | default: 282 | break; 283 | } 284 | } 285 | } 286 | -------------------------------------------------------------------------------- /app/src/main/java/com/amap/placesearch/adapter/InputTipsAdapter.java: -------------------------------------------------------------------------------- 1 | package com.amap.placesearch.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.TextView; 9 | 10 | import com.amap.api.services.help.Tip; 11 | import com.amap.placesearch.R; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * 输入提示adapter,展示item名称和地址 17 | * Created by ligen on 16/11/25. 18 | */ 19 | public class InputTipsAdapter extends BaseAdapter { 20 | private Context mContext; 21 | private List mListTips; 22 | 23 | public InputTipsAdapter(Context context, List tipList) { 24 | mContext = context; 25 | mListTips = tipList; 26 | } 27 | 28 | @Override 29 | public int getCount() { 30 | if (mListTips != null) { 31 | return mListTips.size(); 32 | } 33 | return 0; 34 | } 35 | 36 | 37 | @Override 38 | public Object getItem(int i) { 39 | if (mListTips != null) { 40 | return mListTips.get(i); 41 | } 42 | return null; 43 | } 44 | 45 | @Override 46 | public long getItemId(int i) { 47 | return i; 48 | } 49 | 50 | @Override 51 | public View getView(int i, View view, ViewGroup viewGroup) { 52 | Holder holder; 53 | if (view == null) { 54 | holder = new Holder(); 55 | view = LayoutInflater.from(mContext).inflate(R.layout.adapter_inputtips, null); 56 | holder.mName = (TextView) view.findViewById(R.id.name); 57 | holder.mAddress = (TextView) view.findViewById(R.id.adress); 58 | view.setTag(holder); 59 | } else{ 60 | holder = (Holder)view.getTag(); 61 | } 62 | if(mListTips == null){ 63 | return view; 64 | } 65 | 66 | holder.mName.setText(mListTips.get(i).getName()); 67 | String address = mListTips.get(i).getAddress(); 68 | if(address == null || address.equals("")){ 69 | holder.mAddress.setVisibility(View.GONE); 70 | }else{ 71 | holder.mAddress.setVisibility(View.VISIBLE); 72 | holder.mAddress.setText(address); 73 | } 74 | 75 | return view; 76 | } 77 | 78 | class Holder { 79 | TextView mName; 80 | TextView mAddress; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /app/src/main/java/com/amap/placesearch/overlay/PoiOverlay.java: -------------------------------------------------------------------------------- 1 | package com.amap.placesearch.overlay; 2 | 3 | import com.amap.api.maps.AMap; 4 | import com.amap.api.maps.CameraUpdateFactory; 5 | import com.amap.api.maps.model.BitmapDescriptor; 6 | import com.amap.api.maps.model.LatLng; 7 | import com.amap.api.maps.model.LatLngBounds; 8 | import com.amap.api.maps.model.Marker; 9 | import com.amap.api.maps.model.MarkerOptions; 10 | import com.amap.api.services.core.PoiItem; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * Poi图层类。在高德地图API里,如果要显示Poi,可以用此类来创建Poi图层。如不满足需求,也可以自己创建自定义的Poi图层。 17 | */ 18 | public class PoiOverlay { 19 | private List mPois; 20 | private AMap mAMap; 21 | private ArrayList mPoiMarks = new ArrayList(); 22 | /** 23 | * 通过此构造函数创建Poi图层。 24 | * @param amap 地图对象。 25 | * @param pois 要在地图上添加的poi。列表中的poi对象详见搜索服务模块的基础核心包(com.amap.api.services.core)中的类 PoiItem。 26 | * @since V2.1.0 27 | */ 28 | public PoiOverlay(AMap amap, List pois) { 29 | mAMap = amap; 30 | mPois = pois; 31 | } 32 | /** 33 | * 添加Marker到地图中。 34 | */ 35 | public void addToMap() { 36 | try{ 37 | for (int i = 0; i < mPois.size(); i++) { 38 | Marker marker = mAMap.addMarker(getMarkerOptions(i)); 39 | marker.setObject(i); 40 | mPoiMarks.add(marker); 41 | } 42 | }catch(Throwable e){ 43 | e.printStackTrace(); 44 | } 45 | } 46 | /** 47 | * 去掉PoiOverlay上所有的Marker。 48 | */ 49 | public void removeFromMap() { 50 | for (Marker mark : mPoiMarks) { 51 | mark.remove(); 52 | } 53 | } 54 | /** 55 | * 移动镜头到当前的视角。 56 | */ 57 | public void zoomToSpan() { 58 | try{ 59 | if (mPois != null && mPois.size() > 0) { 60 | if (mAMap == null) 61 | return; 62 | if(mPois.size()==1){ 63 | mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(mPois.get(0).getLatLonPoint().getLatitude(), 64 | mPois.get(0).getLatLonPoint().getLongitude()), 18f)); 65 | }else{ 66 | LatLngBounds bounds = getLatLngBounds(); 67 | mAMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 30)); 68 | } 69 | } 70 | }catch(Throwable e){ 71 | e.printStackTrace(); 72 | } 73 | } 74 | 75 | private LatLngBounds getLatLngBounds() { 76 | LatLngBounds.Builder b = LatLngBounds.builder(); 77 | for (int i = 0; i < mPois.size(); i++) { 78 | b.include(new LatLng(mPois.get(i).getLatLonPoint().getLatitude(), 79 | mPois.get(i).getLatLonPoint().getLongitude())); 80 | } 81 | return b.build(); 82 | } 83 | 84 | private MarkerOptions getMarkerOptions(int index) { 85 | return new MarkerOptions() 86 | .position( 87 | new LatLng(mPois.get(index).getLatLonPoint() 88 | .getLatitude(), mPois.get(index) 89 | .getLatLonPoint().getLongitude())) 90 | .title(getTitle(index)).snippet(getSnippet(index)) 91 | .icon(getBitmapDescriptor(index)); 92 | } 93 | /** 94 | * 给第几个Marker设置图标,并返回更换图标的图片。如不用默认图片,需要重写此方法。 95 | * @param index 第几个Marker。 96 | * @return 更换的Marker图片。 97 | */ 98 | protected BitmapDescriptor getBitmapDescriptor(int index) { 99 | return null; 100 | } 101 | /** 102 | * 返回第index的Marker的标题。 103 | * @param index 第几个Marker。 104 | * @return marker的标题。 105 | */ 106 | protected String getTitle(int index) { 107 | return mPois.get(index).getTitle(); 108 | } 109 | /** 110 | * 返回第index的Marker的详情。 111 | * @param index 第几个Marker。 112 | * @return marker的详情。 113 | */ 114 | protected String getSnippet(int index) { 115 | return mPois.get(index).getSnippet(); 116 | } 117 | /** 118 | * 从marker中得到poi在list的位置。 119 | * @param marker 一个标记的对象。 120 | * @return 返回该marker对应的poi在list的位置。 121 | * @since V2.1.0 122 | */ 123 | public int getPoiIndex(Marker marker) { 124 | for (int i = 0; i < mPoiMarks.size(); i++) { 125 | if (mPoiMarks.get(i).equals(marker)) { 126 | return i; 127 | } 128 | } 129 | return -1; 130 | } 131 | /** 132 | * 返回第index的poi的信息。 133 | * @param index 第几个poi。 134 | * @return poi的信息。poi对象详见搜索服务模块的基础核心包(com.amap.api.services.core)中的类 PoiItem。 135 | */ 136 | public PoiItem getPoiItem(int index) { 137 | if (index < 0 || index >= mPois.size()) { 138 | return null; 139 | } 140 | return mPois.get(index); 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /app/src/main/java/com/amap/placesearch/util/Constants.java: -------------------------------------------------------------------------------- 1 | package com.amap.placesearch.util; 2 | 3 | import com.amap.api.maps.model.LatLng; 4 | 5 | public class Constants { 6 | 7 | public static String DEFAULT_CITY = "北京"; 8 | public static final String EXTRA_TIP = "ExtraTip"; 9 | public static final String KEY_WORDS_NAME = "KeyWord"; 10 | 11 | public static final LatLng BEIJING = new LatLng(39.90403, 116.407525);// 北京市经纬度 12 | public static final LatLng ZHONGGUANCUN = new LatLng(39.983456, 116.3154950);// 北京市中关村经纬度 13 | public static final LatLng SHANGHAI = new LatLng(31.238068, 121.501654);// 上海市经纬度 14 | public static final LatLng FANGHENG = new LatLng(39.989614, 116.481763);// 方恒国际中心经纬度 15 | public static final LatLng CHENGDU = new LatLng(30.679879, 104.064855);// 成都市经纬度 16 | public static final LatLng XIAN = new LatLng(34.341568, 108.940174);// 西安市经纬度 17 | public static final LatLng ZHENGZHOU = new LatLng(34.7466, 113.625367);// 郑州市经纬度 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/amap/placesearch/util/ToastUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.amap.placesearch.util; 5 | 6 | import com.amap.api.services.core.AMapException; 7 | 8 | import android.content.Context; 9 | import android.widget.Toast; 10 | 11 | public class ToastUtil { 12 | 13 | public static void show(Context context, String info) { 14 | Toast.makeText(context, info, Toast.LENGTH_LONG).show(); 15 | } 16 | 17 | public static void show(Context context, int info) { 18 | Toast.makeText(context, info, Toast.LENGTH_LONG).show(); 19 | } 20 | 21 | public static void showerror(Context context, int rCode){ 22 | try { 23 | switch (rCode) { 24 | //服务错误码 25 | case 1001: 26 | throw new AMapException(AMapException.AMAP_SIGNATURE_ERROR); 27 | case 1002: 28 | throw new AMapException(AMapException.AMAP_INVALID_USER_KEY); 29 | case 1003: 30 | throw new AMapException(AMapException.AMAP_SERVICE_NOT_AVAILBALE); 31 | case 1004: 32 | throw new AMapException(AMapException.AMAP_DAILY_QUERY_OVER_LIMIT); 33 | case 1005: 34 | throw new AMapException(AMapException.AMAP_ACCESS_TOO_FREQUENT); 35 | case 1006: 36 | throw new AMapException(AMapException.AMAP_INVALID_USER_IP); 37 | case 1007: 38 | throw new AMapException(AMapException.AMAP_INVALID_USER_DOMAIN); 39 | case 1008: 40 | throw new AMapException(AMapException.AMAP_INVALID_USER_SCODE); 41 | case 1009: 42 | throw new AMapException(AMapException.AMAP_USERKEY_PLAT_NOMATCH); 43 | case 1010: 44 | throw new AMapException(AMapException.AMAP_IP_QUERY_OVER_LIMIT); 45 | case 1011: 46 | throw new AMapException(AMapException.AMAP_NOT_SUPPORT_HTTPS); 47 | case 1012: 48 | throw new AMapException(AMapException.AMAP_INSUFFICIENT_PRIVILEGES); 49 | case 1013: 50 | throw new AMapException(AMapException.AMAP_USER_KEY_RECYCLED); 51 | case 1100: 52 | throw new AMapException(AMapException.AMAP_ENGINE_RESPONSE_ERROR); 53 | case 1101: 54 | throw new AMapException(AMapException.AMAP_ENGINE_RESPONSE_DATA_ERROR); 55 | case 1102: 56 | throw new AMapException(AMapException.AMAP_ENGINE_CONNECT_TIMEOUT); 57 | case 1103: 58 | throw new AMapException(AMapException.AMAP_ENGINE_RETURN_TIMEOUT); 59 | case 1200: 60 | throw new AMapException(AMapException.AMAP_SERVICE_INVALID_PARAMS); 61 | case 1201: 62 | throw new AMapException(AMapException.AMAP_SERVICE_MISSING_REQUIRED_PARAMS); 63 | case 1202: 64 | throw new AMapException(AMapException.AMAP_SERVICE_ILLEGAL_REQUEST); 65 | case 1203: 66 | throw new AMapException(AMapException.AMAP_SERVICE_UNKNOWN_ERROR); 67 | //sdk返回错误 68 | case 1800: 69 | throw new AMapException(AMapException.AMAP_CLIENT_ERRORCODE_MISSSING); 70 | case 1801: 71 | throw new AMapException(AMapException.AMAP_CLIENT_ERROR_PROTOCOL); 72 | case 1802: 73 | throw new AMapException(AMapException.AMAP_CLIENT_SOCKET_TIMEOUT_EXCEPTION); 74 | case 1803: 75 | throw new AMapException(AMapException.AMAP_CLIENT_URL_EXCEPTION); 76 | case 1804: 77 | throw new AMapException(AMapException.AMAP_CLIENT_UNKNOWHOST_EXCEPTION); 78 | case 1806: 79 | throw new AMapException(AMapException.AMAP_CLIENT_NETWORK_EXCEPTION); 80 | case 1900: 81 | throw new AMapException(AMapException.AMAP_CLIENT_UNKNOWN_ERROR); 82 | case 1901: 83 | throw new AMapException(AMapException.AMAP_CLIENT_INVALID_PARAMETER); 84 | case 1902: 85 | throw new AMapException(AMapException.AMAP_CLIENT_IO_EXCEPTION); 86 | case 1903: 87 | throw new AMapException(AMapException.AMAP_CLIENT_NULLPOINT_EXCEPTION); 88 | //云图和附近错误码 89 | case 2000: 90 | throw new AMapException(AMapException.AMAP_SERVICE_TABLEID_NOT_EXIST); 91 | case 2001: 92 | throw new AMapException(AMapException.AMAP_ID_NOT_EXIST); 93 | case 2002: 94 | throw new AMapException(AMapException.AMAP_SERVICE_MAINTENANCE); 95 | case 2003: 96 | throw new AMapException(AMapException.AMAP_ENGINE_TABLEID_NOT_EXIST); 97 | case 2100: 98 | throw new AMapException(AMapException.AMAP_NEARBY_INVALID_USERID); 99 | case 2101: 100 | throw new AMapException(AMapException.AMAP_NEARBY_KEY_NOT_BIND); 101 | case 2200: 102 | throw new AMapException(AMapException.AMAP_CLIENT_UPLOADAUTO_STARTED_ERROR); 103 | case 2201: 104 | throw new AMapException(AMapException.AMAP_CLIENT_USERID_ILLEGAL); 105 | case 2202: 106 | throw new AMapException(AMapException.AMAP_CLIENT_NEARBY_NULL_RESULT); 107 | case 2203: 108 | throw new AMapException(AMapException.AMAP_CLIENT_UPLOAD_TOO_FREQUENT); 109 | case 2204: 110 | throw new AMapException(AMapException.AMAP_CLIENT_UPLOAD_LOCATION_ERROR); 111 | //路径规划 112 | case 3000: 113 | throw new AMapException(AMapException.AMAP_ROUTE_OUT_OF_SERVICE); 114 | case 3001: 115 | throw new AMapException(AMapException.AMAP_ROUTE_NO_ROADS_NEARBY); 116 | case 3002: 117 | throw new AMapException(AMapException.AMAP_ROUTE_FAIL); 118 | case 3003: 119 | throw new AMapException(AMapException.AMAP_OVER_DIRECTION_RANGE); 120 | //短传分享 121 | case 4000: 122 | throw new AMapException(AMapException.AMAP_SHARE_LICENSE_IS_EXPIRED); 123 | case 4001: 124 | throw new AMapException(AMapException.AMAP_SHARE_FAILURE); 125 | default: 126 | Toast.makeText(context,"查询失败:"+rCode , Toast.LENGTH_LONG).show(); 127 | break; 128 | } 129 | } catch (Exception e) { 130 | Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show(); 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/back.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/start_uri.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/drawable/start_uri.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/text_search.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/text_search_default.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/drawable/text_search_default.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/text_search_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/drawable/text_search_pressed.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/text_search_selected.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/drawable/text_search_selected.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/title_background.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/drawable/title_background.9.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_input_tips.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 17 | 18 | 29 | 30 | 42 | 43 | 44 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 14 | 21 | 22 | 31 | 32 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /app/src/main/res/layout/adapter_inputtips.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 19 | 20 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/poikeywordsearch_uri.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/menu/options_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_arrow_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-hdpi/ic_arrow_back.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-hdpi/ic_close.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_keyboard_voice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-hdpi/ic_keyboard_voice.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-hdpi/ic_search.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_arrow_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-mdpi/ic_arrow_back.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-mdpi/ic_close.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_keyboard_voice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-mdpi/ic_keyboard_voice.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-mdpi/ic_search.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_arrow_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-xhdpi/ic_arrow_back.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-xhdpi/ic_close.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_keyboard_voice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-xhdpi/ic_keyboard_voice.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-xhdpi/ic_search.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_arrow_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-xxhdpi/ic_arrow_back.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-xxhdpi/ic_close.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_keyboard_voice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-xxhdpi/ic_keyboard_voice.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-xxhdpi/ic_search.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #C0C0C0 7 | #ebebeb 8 | #FFF 9 | #6C6C6C 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 兴趣点搜索 3 | 对不起,没有搜索到相关数据! 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/test/java/com/amap/placesearch/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.amap.placesearch; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.3.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Jul 13 11:08:53 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /resource/Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/resource/Screenshot.png -------------------------------------------------------------------------------- /resource/ScreenshotPoiSearch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/resource/ScreenshotPoiSearch.png -------------------------------------------------------------------------------- /resource/app-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/resource/app-debug.apk -------------------------------------------------------------------------------- /resource/download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/android-place-search/45f7cb911504edfdf424afd0b5d5f78b47f373f8/resource/download.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------