├── app
├── .gitignore
├── libs
│ ├── BaiduLBS_Android.jar
│ ├── x86
│ │ ├── liblocSDK6a.so
│ │ ├── libBaiduMapSDK_map_v3_6_1.so
│ │ ├── libBaiduMapSDK_base_v3_6_1.so
│ │ ├── libBaiduMapSDK_cloud_v3_6_1.so
│ │ ├── libBaiduMapSDK_radar_v3_6_1.so
│ │ ├── libBaiduMapSDK_search_v3_6_1.so
│ │ └── libBaiduMapSDK_util_v3_6_1.so
│ ├── armeabi
│ │ ├── liblocSDK6a.so
│ │ ├── libBaiduMapSDK_base_v3_6_1.so
│ │ ├── libBaiduMapSDK_map_v3_6_1.so
│ │ ├── libBaiduMapSDK_util_v3_6_1.so
│ │ ├── libBaiduMapSDK_cloud_v3_6_1.so
│ │ ├── libBaiduMapSDK_radar_v3_6_1.so
│ │ └── libBaiduMapSDK_search_v3_6_1.so
│ ├── x86_64
│ │ ├── liblocSDK6a.so
│ │ ├── libBaiduMapSDK_map_v3_6_1.so
│ │ ├── libBaiduMapSDK_base_v3_6_1.so
│ │ ├── libBaiduMapSDK_cloud_v3_6_1.so
│ │ ├── libBaiduMapSDK_radar_v3_6_1.so
│ │ ├── libBaiduMapSDK_util_v3_6_1.so
│ │ └── libBaiduMapSDK_search_v3_6_1.so
│ ├── arm64-v8a
│ │ ├── liblocSDK6a.so
│ │ ├── libBaiduMapSDK_base_v3_6_1.so
│ │ ├── libBaiduMapSDK_cloud_v3_6_1.so
│ │ ├── libBaiduMapSDK_map_v3_6_1.so
│ │ ├── libBaiduMapSDK_radar_v3_6_1.so
│ │ ├── libBaiduMapSDK_util_v3_6_1.so
│ │ └── libBaiduMapSDK_search_v3_6_1.so
│ └── armeabi-v7a
│ │ ├── liblocSDK6a.so
│ │ ├── libBaiduMapSDK_map_v3_6_1.so
│ │ ├── libBaiduMapSDK_base_v3_6_1.so
│ │ ├── libBaiduMapSDK_cloud_v3_6_1.so
│ │ ├── libBaiduMapSDK_radar_v3_6_1.so
│ │ ├── libBaiduMapSDK_util_v3_6_1.so
│ │ └── libBaiduMapSDK_search_v3_6_1.so
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── marker_icon.png
│ │ │ │ ├── search_img.png
│ │ │ │ ├── dingwei_icon.png
│ │ │ │ └── clear_normal_list.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable
│ │ │ │ └── city_search_et_bg.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── item_near_address.xml
│ │ │ │ ├── item_search_address.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── activity_service_location.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── gu
│ │ │ │ └── test
│ │ │ │ ├── adapter
│ │ │ │ ├── NearAddressAdapter.java
│ │ │ │ ├── SearchAddressAdapter.java
│ │ │ │ └── base
│ │ │ │ │ ├── BaseViewHolder.java
│ │ │ │ │ └── MyBaseAdapter.java
│ │ │ │ ├── activity
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── LocationActivity.java
│ │ │ │ └── view
│ │ │ │ └── ClearEditText.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── gu
│ │ │ └── test
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── gu
│ │ └── test
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── imgs
├── 1.png
├── 2.png
├── 3.png
└── 58到家效果.gif
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── README.md
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/imgs/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/imgs/1.png
--------------------------------------------------------------------------------
/imgs/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/imgs/2.png
--------------------------------------------------------------------------------
/imgs/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/imgs/3.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | gradle
3 | .gradle
4 | .idea
5 | build
6 | app/build
7 | local.properties
8 |
--------------------------------------------------------------------------------
/imgs/58到家效果.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/imgs/58到家效果.gif
--------------------------------------------------------------------------------
/app/libs/BaiduLBS_Android.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/BaiduLBS_Android.jar
--------------------------------------------------------------------------------
/app/libs/x86/liblocSDK6a.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/x86/liblocSDK6a.so
--------------------------------------------------------------------------------
/app/libs/armeabi/liblocSDK6a.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/armeabi/liblocSDK6a.so
--------------------------------------------------------------------------------
/app/libs/x86_64/liblocSDK6a.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/x86_64/liblocSDK6a.so
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BaiduMapSelectAddress
3 |
4 |
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/liblocSDK6a.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/arm64-v8a/liblocSDK6a.so
--------------------------------------------------------------------------------
/app/libs/armeabi-v7a/liblocSDK6a.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/armeabi-v7a/liblocSDK6a.so
--------------------------------------------------------------------------------
/app/libs/x86/libBaiduMapSDK_map_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/x86/libBaiduMapSDK_map_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/x86/libBaiduMapSDK_base_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/x86/libBaiduMapSDK_base_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/x86/libBaiduMapSDK_cloud_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/x86/libBaiduMapSDK_cloud_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/x86/libBaiduMapSDK_radar_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/x86/libBaiduMapSDK_radar_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/x86/libBaiduMapSDK_search_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/x86/libBaiduMapSDK_search_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/x86/libBaiduMapSDK_util_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/x86/libBaiduMapSDK_util_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/x86_64/libBaiduMapSDK_map_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/x86_64/libBaiduMapSDK_map_v3_6_1.so
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/marker_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/src/main/res/mipmap-hdpi/marker_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/search_img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/src/main/res/mipmap-hdpi/search_img.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/libs/armeabi/libBaiduMapSDK_base_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/armeabi/libBaiduMapSDK_base_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libBaiduMapSDK_map_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/armeabi/libBaiduMapSDK_map_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libBaiduMapSDK_util_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/armeabi/libBaiduMapSDK_util_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/x86_64/libBaiduMapSDK_base_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/x86_64/libBaiduMapSDK_base_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/x86_64/libBaiduMapSDK_cloud_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/x86_64/libBaiduMapSDK_cloud_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/x86_64/libBaiduMapSDK_radar_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/x86_64/libBaiduMapSDK_radar_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/x86_64/libBaiduMapSDK_util_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/x86_64/libBaiduMapSDK_util_v3_6_1.so
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/dingwei_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/src/main/res/mipmap-hdpi/dingwei_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libBaiduMapSDK_base_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/arm64-v8a/libBaiduMapSDK_base_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libBaiduMapSDK_cloud_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/arm64-v8a/libBaiduMapSDK_cloud_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libBaiduMapSDK_map_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/arm64-v8a/libBaiduMapSDK_map_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libBaiduMapSDK_radar_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/arm64-v8a/libBaiduMapSDK_radar_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libBaiduMapSDK_util_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/arm64-v8a/libBaiduMapSDK_util_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/armeabi-v7a/libBaiduMapSDK_map_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/armeabi-v7a/libBaiduMapSDK_map_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libBaiduMapSDK_cloud_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/armeabi/libBaiduMapSDK_cloud_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libBaiduMapSDK_radar_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/armeabi/libBaiduMapSDK_radar_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libBaiduMapSDK_search_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/armeabi/libBaiduMapSDK_search_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/x86_64/libBaiduMapSDK_search_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/x86_64/libBaiduMapSDK_search_v3_6_1.so
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libBaiduMapSDK_search_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/arm64-v8a/libBaiduMapSDK_search_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/armeabi-v7a/libBaiduMapSDK_base_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/armeabi-v7a/libBaiduMapSDK_base_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/armeabi-v7a/libBaiduMapSDK_cloud_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/armeabi-v7a/libBaiduMapSDK_cloud_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/armeabi-v7a/libBaiduMapSDK_radar_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/armeabi-v7a/libBaiduMapSDK_radar_v3_6_1.so
--------------------------------------------------------------------------------
/app/libs/armeabi-v7a/libBaiduMapSDK_util_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/armeabi-v7a/libBaiduMapSDK_util_v3_6_1.so
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/clear_normal_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/src/main/res/mipmap-hdpi/clear_normal_list.png
--------------------------------------------------------------------------------
/app/libs/armeabi-v7a/libBaiduMapSDK_search_v3_6_1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NateRobinson/BaiduMapSelectAddress/HEAD/app/libs/armeabi-v7a/libBaiduMapSDK_search_v3_6_1.so
--------------------------------------------------------------------------------
/app/src/main/res/drawable/city_search_et_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/test/java/com/gu/test/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.gu.test;
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 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/gu/test/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.gu.test;
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/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/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 D:\Android\sdk/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/main/java/com/gu/test/adapter/NearAddressAdapter.java:
--------------------------------------------------------------------------------
1 | package com.gu.test.adapter;
2 |
3 | import java.util.List;
4 |
5 | import android.content.Context;
6 |
7 | import com.baidu.mapapi.search.core.PoiInfo;
8 | import com.gu.test.R;
9 | import com.gu.test.adapter.base.BaseViewHolder;
10 | import com.gu.test.adapter.base.MyBaseAdapter;
11 |
12 | /**
13 | * @desc 附近的地址列表适配器
14 | * @author Nate
15 | * @date 2015-12-20
16 | */
17 | public class NearAddressAdapter extends MyBaseAdapter {
18 |
19 | public NearAddressAdapter(Context context, int resource, List list) {
20 | super(context, resource, list);
21 | }
22 |
23 | @Override
24 | public void setConvert(BaseViewHolder viewHolder, PoiInfo info) {
25 | viewHolder.setTextView(R.id.item_address_name_tv, info.name);
26 | viewHolder.setTextView(R.id.item_address_detail_tv, info.address);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gu/test/adapter/SearchAddressAdapter.java:
--------------------------------------------------------------------------------
1 | package com.gu.test.adapter;
2 |
3 | import java.util.List;
4 |
5 | import android.content.Context;
6 |
7 | import com.baidu.mapapi.search.core.PoiInfo;
8 | import com.gu.test.R;
9 | import com.gu.test.adapter.base.BaseViewHolder;
10 | import com.gu.test.adapter.base.MyBaseAdapter;
11 |
12 | /**
13 | * @desc 搜索的地址列表适配器
14 | * @author Nate
15 | * @date 2015-12-20
16 | */
17 | public class SearchAddressAdapter extends MyBaseAdapter {
18 |
19 | public SearchAddressAdapter(Context context, int resource, List list) {
20 | super(context, resource, list);
21 | }
22 |
23 | @Override
24 | public void setConvert(BaseViewHolder viewHolder, PoiInfo info) {
25 | viewHolder.setTextView(R.id.item_address_name_tv, info.name);
26 | viewHolder.setTextView(R.id.item_address_detail_tv, info.address);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.gu.test"
9 | minSdkVersion 14
10 | targetSdkVersion 23
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 | sourceSets {
22 | main {
23 | jniLibs.srcDirs = ['libs']
24 | }
25 | }
26 | }
27 |
28 | dependencies {
29 | compile fileTree(dir: 'libs', include: ['*.jar'])
30 | testCompile 'junit:junit:4.12'
31 | compile 'com.android.support:appcompat-v7:23.1.0'
32 | compile 'com.jakewharton:butterknife:5.1.1'
33 | }
34 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_near_address.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
23 |
24 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_search_address.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
23 |
24 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
18 |
19 |
26 |
27 |
34 |
35 |
42 |
43 |
50 |
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gu/test/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gu.test.activity;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.widget.TextView;
8 |
9 | import com.baidu.mapapi.SDKInitializer;
10 | import com.gu.test.R;
11 |
12 | import butterknife.ButterKnife;
13 | import butterknife.InjectView;
14 |
15 | public class MainActivity extends AppCompatActivity {
16 | private static final int GO_FOR_BAIDU_MAP = 1;
17 | @InjectView(R.id.lng_tv)
18 | TextView lngTv;
19 | @InjectView(R.id.lat_tv)
20 | TextView latTv;
21 | @InjectView(R.id.address_name_tv)
22 | TextView addressNameTv;
23 | @InjectView(R.id.address_detail_tv)
24 | TextView addressDetailTv;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_main);
30 | ButterKnife.inject(this);
31 | // 百度地图初始化
32 | SDKInitializer.initialize(getApplicationContext());
33 |
34 | findViewById(R.id.go_in_location_btn).setOnClickListener(new View.OnClickListener() {
35 | @Override
36 | public void onClick(View v) {
37 | Intent intent = new Intent(MainActivity.this, LocationActivity.class);
38 | startActivityForResult(intent, GO_FOR_BAIDU_MAP);
39 | }
40 | });
41 | }
42 |
43 |
44 | @Override
45 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
46 | if (resultCode == RESULT_OK && requestCode == GO_FOR_BAIDU_MAP
47 | && data != null && data.getExtras() != null) {
48 | lngTv.setText("经度:"+data.getStringExtra("Ing"));
49 | latTv.setText("维度:"+data.getStringExtra("Iat"));
50 | addressNameTv.setText("地址名:"+data.getStringExtra("Address"));
51 | addressDetailTv.setText("详细地址:"+data.getStringExtra("DetailedAddress"));
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
49 |
50 |
54 |
55 |
56 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gu/test/view/ClearEditText.java:
--------------------------------------------------------------------------------
1 | package com.gu.test.view;
2 |
3 | import android.content.Context;
4 | import android.graphics.drawable.Drawable;
5 | import android.text.Editable;
6 | import android.text.TextWatcher;
7 | import android.util.AttributeSet;
8 | import android.view.MotionEvent;
9 | import android.view.View;
10 | import android.widget.EditText;
11 |
12 | import com.gu.test.R;
13 |
14 |
15 | /**
16 | *
17 | * @desc 带删除按钮的输入框
18 | * @author Nate
19 | * @date 2015-12-18
20 | */
21 | public class ClearEditText extends EditText {
22 |
23 | // 回调函数
24 | private TextWatcherCallBack mCallback;
25 | // 右侧删除图标
26 | private Drawable mDrawable;
27 | private Context mContext;
28 |
29 | public void setCallBack(TextWatcherCallBack mCallback) {
30 | this.mCallback = mCallback;
31 | }
32 |
33 | public ClearEditText(Context context) {
34 | super(context);
35 | this.mContext = context;
36 | init();
37 | }
38 |
39 | public ClearEditText(Context context, AttributeSet attrs) {
40 | super(context, attrs);
41 | this.mContext = context;
42 | init();
43 | }
44 |
45 | public ClearEditText(Context context, AttributeSet attrs, int defStyle) {
46 | super(context, attrs, defStyle);
47 | this.mContext = context;
48 | init();
49 | }
50 |
51 | public void init() {
52 | mDrawable = mContext.getResources().getDrawable(
53 | R.mipmap.clear_normal_list);
54 | mCallback = null;
55 | // 重写了TextWatcher,在具体实现时就不用每个方法都实现,减少代码量
56 | TextWatcher textWatcher = new TextWatcher() {
57 | @Override
58 | public void beforeTextChanged(CharSequence s, int start, int count,
59 | int after) {
60 |
61 | }
62 |
63 | @Override
64 | public void onTextChanged(CharSequence s, int start, int before,
65 | int count) {
66 |
67 | }
68 |
69 | @Override
70 | public void afterTextChanged(Editable s) {
71 | // 更新状态,检查是否显示删除按钮
72 | updateCleanable(length(), true);
73 | // 如果有在activity中设置回调,则此处可以触发
74 | if (mCallback != null)
75 | mCallback.handleMoreTextChanged();
76 | }
77 | };
78 | this.addTextChangedListener(textWatcher);
79 | this.setOnFocusChangeListener(new OnFocusChangeListener() {
80 |
81 | @Override
82 | public void onFocusChange(View v, boolean hasFocus) {
83 | // 更新状态,检查是否显示删除按钮
84 | updateCleanable(length(), hasFocus);
85 | }
86 | });
87 | }
88 |
89 | // 当内容不为空,而且获得焦点,才显示右侧删除按钮
90 | public void updateCleanable(int length, boolean hasFocus) {
91 | if (length() > 0 && hasFocus)
92 | setCompoundDrawablesWithIntrinsicBounds(null, null, mDrawable, null);
93 | else
94 | setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
95 | }
96 |
97 | @Override
98 | public boolean onTouchEvent(MotionEvent event) {
99 | final int DRAWABLE_RIGHT = 2;
100 | // 可以获得上下左右四个drawable,右侧排第二。图标没有设置则为空。
101 | Drawable rightIcon = getCompoundDrawables()[DRAWABLE_RIGHT];
102 | if (rightIcon != null && event.getAction() == MotionEvent.ACTION_UP) {
103 | // 检查点击的位置是否是右侧的删除图标
104 | // 注意,使用getRwwX()是获取相对屏幕的位置,getX()可能获取相对父组件的位置
105 | int leftEdgeOfRightDrawable = getRight() - getPaddingRight()
106 | - rightIcon.getBounds().width();
107 | if (event.getRawX() >= leftEdgeOfRightDrawable) {
108 | setText("");
109 | }
110 | }
111 | return super.onTouchEvent(event);
112 | }
113 |
114 | @Override
115 | protected void finalize() throws Throwable {
116 | mDrawable = null;
117 | super.finalize();
118 | }
119 |
120 | public interface TextWatcherCallBack {
121 | void handleMoreTextChanged();
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gu/test/adapter/base/BaseViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.gu.test.adapter.base;
2 |
3 | import android.content.Context;
4 | import android.text.SpannableString;
5 | import android.text.Spanned;
6 | import android.util.SparseArray;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ImageView;
11 | import android.widget.TextView;
12 |
13 | /**
14 | * @author Nate
15 | * @ClassName: BaseViewHolder
16 | * @Description: ViewHolder封装类
17 | * @date 2015年4月26日 上午10:03:34
18 | */
19 | public class BaseViewHolder {
20 | /**
21 | * 视图容器
22 | */
23 | private SparseArray mViews;
24 |
25 | /**
26 | * 位置标识
27 | */
28 | private int mPosition;
29 |
30 | /**
31 | * 视图
32 | */
33 | private View mConvertView;
34 |
35 | /**
36 | * 私有化构造方法,不让外界进行使用
37 | *
38 | * @param context
39 | * @param parent
40 | * @param layoutId
41 | * @param position
42 | */
43 | private BaseViewHolder(Context context, ViewGroup parent, int layoutId,
44 | int position) {
45 | this.mViews = new SparseArray();
46 | this.mConvertView = LayoutInflater.from(context).inflate(layoutId,
47 | parent, false);
48 | this.mPosition = position;
49 | mConvertView.setTag(this);
50 | }
51 |
52 | /**
53 | * @param context
54 | * @param parent
55 | * @param layoutId
56 | * @param position
57 | * @param convertView
58 | * @return 静态方法获取到viewholder类实例
59 | */
60 | public static BaseViewHolder get(Context context, ViewGroup parent,
61 | int layoutId, int position, View convertView) {
62 | if (convertView == null) {
63 | return new BaseViewHolder(context, parent, layoutId, position);
64 | } else {
65 | BaseViewHolder holder = (BaseViewHolder) convertView.getTag();
66 | // 复用视图,但是position要更新
67 | holder.mPosition = position;
68 | return holder;
69 | }
70 | }
71 |
72 | /**
73 | * @param viewId
74 | * 控件id
75 | * @return 根据控件id获取到控件
76 | */
77 | @SuppressWarnings("unchecked")
78 | public T getView(int viewId) {
79 | View view = mViews.get(viewId);
80 | if (view == null) {
81 | view = mConvertView.findViewById(viewId);
82 | mViews.put(viewId, view);
83 | }
84 | return (T) view;
85 | }
86 |
87 | /**
88 | * @return 返回视图类
89 | */
90 | public View getConvertView() {
91 | return mConvertView;
92 | }
93 |
94 | /**
95 | * 返回当前的position
96 | */
97 | public int getPosition() {
98 | return mPosition;
99 | }
100 |
101 | /**
102 | * @return 设置textview相关
103 | */
104 | public BaseViewHolder setTextView(int viewId, String content) {
105 | TextView tv = getView(viewId);
106 | tv.setText(content);
107 | return this;
108 | }
109 |
110 | public BaseViewHolder setTextView(int viewId, Spanned content) {
111 | TextView tv = getView(viewId);
112 | tv.setText(content);
113 | return this;
114 | }
115 |
116 | /**
117 | * 设置textview相关
118 | *
119 | * @param viewId
120 | * @param content
121 | * @return
122 | */
123 | public BaseViewHolder setTextView(int viewId, SpannableString content) {
124 | TextView tv = getView(viewId);
125 | tv.setText(content);
126 | return this;
127 | }
128 |
129 | /**
130 | * 设置textview相关
131 | *
132 | * @param viewId
133 | * @param content
134 | * @return
135 | */
136 | public BaseViewHolder setTextView(int viewId, int content) {
137 | TextView tv = getView(viewId);
138 | tv.setText(content);
139 | return this;
140 | }
141 |
142 | /**
143 | * 展示资源图片
144 | */
145 | public BaseViewHolder setResNorImg(int viewId, int resourceId) {
146 | ImageView iv = getView(viewId);
147 | iv.setImageResource(resourceId);
148 | return this;
149 | }
150 | // TODO 可以根据自己的需要编写更多适用的方法。。。
151 | }
152 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gu/test/adapter/base/MyBaseAdapter.java:
--------------------------------------------------------------------------------
1 | package com.gu.test.adapter.base;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.text.TextUtils;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ArrayAdapter;
11 |
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | /**
17 | * @param
18 | * @author Nate
19 | * @ClassName: BaseAdapter
20 | * @Description: 封装的listviewadapter
21 | * @date 2015年4月26日 上午10:06:33
22 | */
23 | public abstract class MyBaseAdapter extends ArrayAdapter {
24 | protected static String TAG_LOG = null;
25 | /**
26 | * listview的item资源id
27 | */
28 | private int resourceId;
29 |
30 | protected List list = new ArrayList();
31 |
32 | public MyBaseAdapter(Context context, int resource, List list) {
33 | super(context, resource, list);
34 | this.list = list;
35 | this.resourceId = resource;
36 | TAG_LOG = this.getClass().getSimpleName();
37 | }
38 |
39 | @Override
40 | public T getItem(int position) {
41 | return list.get(position);
42 | }
43 |
44 | /**
45 | * 根据position移除listview某一项
46 | *
47 | * @param position
48 | */
49 | public void remove(int position) {
50 | this.list.remove(position);
51 | notifyDataSetChanged();
52 | }
53 |
54 | /**
55 | * 根据t对象移除listview某一项
56 | *
57 | * @param t
58 | */
59 | public void remove(T t) {
60 | this.list.remove(t);
61 | notifyDataSetChanged();
62 | }
63 |
64 | /**
65 | * 当ListView数据发生变化时,调用此方法来更新ListView
66 | */
67 | public void updateListView(List list) {
68 | this.list = list;
69 | notifyDataSetChanged();
70 | }
71 |
72 | @Override
73 | public int getCount() {
74 | if (list == null) {
75 | return 0;
76 | }
77 | return list.size();
78 | }
79 |
80 | @Override
81 | public long getItemId(int id) {
82 | return id;
83 | }
84 |
85 | @Override
86 | public View getView(int position, View convertView, ViewGroup parent) {
87 | BaseViewHolder viewHolder = BaseViewHolder.get(getContext(), parent,
88 | resourceId, position, convertView);
89 | // 设置每个item控件
90 | setConvert(viewHolder, getItem(position));
91 | return viewHolder.getConvertView();
92 | }
93 |
94 | /**
95 | * @param @param viewHolder
96 | * @param @param t 设定文件
97 | * @return void 返回类型
98 | * @Title: setConvert
99 | * @Description: 抽象方法,由子类去实现每个itme如何设置
100 | */
101 | public abstract void setConvert(BaseViewHolder viewHolder, T t);
102 |
103 | public void setList(List list) {
104 | this.list = list;
105 | }
106 |
107 | /**
108 | * 跳转另一个活动
109 | *
110 | * @param clazz
111 | */
112 | protected void go(Context context, Class> clazz) {
113 | Intent intent = new Intent(context, clazz);
114 | context.startActivity(intent);
115 | }
116 |
117 | /**
118 | * 跳转另一个活动并传递参数
119 | *
120 | * @param clazz
121 | * @param bundle
122 | */
123 | protected void go(Context context, Class> clazz, Bundle bundle) {
124 | Intent intent = new Intent(context, clazz);
125 | if (null != bundle) {
126 | intent.putExtras(bundle);
127 | }
128 | context.startActivity(intent);
129 | }
130 |
131 | /**
132 | * 跳转另一个活动并结束当前
133 | *
134 | * @param clazz
135 | */
136 | protected void goThenKill(Context context, Class> clazz) {
137 | Intent intent = new Intent(context, clazz);
138 | context.startActivity(intent);
139 | ((Activity) context).finish();
140 | }
141 |
142 | /**
143 | * 跳转另一个活动并结束,并传递参数
144 | *
145 | * @param clazz
146 | * @param bundle
147 | */
148 | protected void goThenKill(Context context, Class> clazz, Bundle bundle) {
149 | Intent intent = new Intent(context, clazz);
150 | if (null != bundle) {
151 | intent.putExtras(bundle);
152 | }
153 | context.startActivity(intent);
154 | ((Activity) context).finish();
155 | }
156 |
157 | }
158 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 模仿58到家百度地图地址选择效果 #
2 |
3 | 先上58到家的效果图:
4 |
5 | 
6 |
7 | 刚好最近有个项目要实现此效果,于是我就去好好研究了一把百度地图API,不得不说,百度地图的类参考文档简直好啊,遇到思绪打不开的时候,看看他的类参考文档,瞬间思路大开[http://wiki.lbsyun.baidu.com/cms/androidsdk/doc/v3_6_1/](http://wiki.lbsyun.baidu.com/cms/androidsdk/doc/v3_6_1/ "http://wiki.lbsyun.baidu.com/cms/androidsdk/doc/v3_6_1/") 我这里用的3.6.1的,所以查看的对应版本的类参考。
8 |
9 | 下面再放上我这个demo实现的效果:
10 |
11 | 地图选择界面1:
12 |
13 | 
14 |
15 | 地图选择界面2:
16 |
17 | 
18 |
19 | 地图选择界面3:
20 |
21 | 
22 |
23 |
24 | ----------
25 |
26 | ## 几个关键点 ##
27 |
28 | 这里用到了几个关键的地方:
29 |
30 | 一:如何设置的marker一直在地图的中间,这里使用了BaiduMap的OnMapStatusChangeListener监听接口:
31 |
32 | mBaiduMap.setOnMapStatusChangeListener(new OnMapStatusChangeListener() {
33 |
34 | @Override
35 | public void onMapStatusChangeStart(MapStatus arg0) {
36 |
37 | }
38 |
39 | @Override
40 | public void onMapStatusChangeFinish(MapStatus arg0) {
41 | search_ll.setVisibility(View.GONE);
42 | mBaiduMap.clear();
43 | mBaiduMap.addOverlay(new MarkerOptions().position(arg0.target)
44 | .icon(mCurrentMarker));
45 | // 反Geo搜索
46 | mSearch.reverseGeoCode(new ReverseGeoCodeOption()
47 | .location(arg0.target));
48 | }
49 |
50 | @Override
51 | public void onMapStatusChange(MapStatus arg0) {
52 |
53 | }
54 | });
55 |
56 | 这个`arg0.target`就是当前map控件的中点位置的坐标,我们可以获取到,然后重新设置一下marker就可以了,不过在之前一定要记得` mBaiduMap.clear();`,不然会出现很多个marker。
57 |
58 | 二:如果通过中点的经纬度获取到周围的地点:使用到了GeoCoder类,这个类可以通过坐标反编译到地址,当然可以获取到这个地址周围的地址:
59 |
60 | public void onGetReverseGeoCodeResult(ReverseGeoCodeResult result) {
61 | if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
62 | Toast.makeText(LocationActivity.this, "抱歉,未能找到结果",
63 | Toast.LENGTH_LONG).show();
64 | return;
65 | }
66 |
67 | //这就是附近地址的列表
68 | List list = result.getPoiList();
69 | if (list != null && list.size() > 0) {
70 | nearAddresses.clear();
71 | nearAddresses.addAll(list);
72 | nearAddressAdapter.notifyDataSetChanged();
73 | }
74 |
75 | }
76 |
77 |
78 | 三:如何实现在输入框中一输入一个关键字,就出来一串地址列表:使用了PoiSearch类,这个类可以通过设置搜索监听事件,来搜索和输入关键字有关联的地址:
79 |
80 | 先给输入框加一个输入监听事件:
81 |
82 | search_et.addTextChangedListener(new TextWatcher() {
83 |
84 | @Override
85 | public void onTextChanged(CharSequence cs, int start, int before,
86 | int count) {
87 | if (cs == null || cs.length() <= 0) {
88 | search_ll.setVisibility(View.GONE);
89 | return;
90 | }
91 |
92 | //发起搜索请求
93 | mPoiSearch.searchInCity((new PoiCitySearchOption())
94 | .city(cityName).keyword(cs.toString()).pageNum(0)
95 | .pageCapacity(20));
96 | }
97 |
98 | @Override
99 | public void beforeTextChanged(CharSequence s, int start, int count,
100 | int after) {
101 |
102 | }
103 |
104 | @Override
105 | public void afterTextChanged(Editable s) {
106 |
107 | }
108 | });
109 |
110 | 然后在搜索结果回调中处理结果并展示出来:
111 |
112 | @Override
113 | public void onGetPoiResult(PoiResult result) {
114 | if (result == null
115 | || result.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) {
116 | return;
117 | }
118 | if (result.error == SearchResult.ERRORNO.NO_ERROR) {
119 | List list = result.getAllPoi();
120 | search_ll.setVisibility(View.VISIBLE);
121 | if (list != null && list.size() > 0) {
122 | searchAddresses.clear();
123 | searchAddresses.addAll(list);
124 | searchAddressAdapter.notifyDataSetChanged();
125 | }
126 | }
127 | }
128 |
129 | 至此一个初步模仿58到家百度地图选择地址的效果就完成啦。通过此文希望和大家一起学习进步。
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_service_location.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
23 |
24 |
30 |
31 |
39 |
40 |
46 |
47 |
58 |
59 |
60 |
61 |
70 |
71 |
72 |
78 |
79 |
87 |
88 |
92 |
93 |
97 |
98 |
99 |
105 |
106 |
112 |
113 |
114 |
115 |
116 |
117 |
123 |
124 |
131 |
132 |
137 |
138 |
139 |
149 |
150 |
151 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gu/test/activity/LocationActivity.java:
--------------------------------------------------------------------------------
1 | package com.gu.test.activity;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.text.Editable;
8 | import android.text.TextWatcher;
9 | import android.view.View;
10 | import android.widget.AdapterView;
11 | import android.widget.AdapterView.OnItemClickListener;
12 | import android.widget.EditText;
13 | import android.widget.LinearLayout;
14 | import android.widget.ListView;
15 | import android.widget.TextView;
16 | import android.widget.Toast;
17 |
18 | import com.baidu.location.BDLocation;
19 | import com.baidu.location.BDLocationListener;
20 | import com.baidu.location.LocationClient;
21 | import com.baidu.location.LocationClientOption;
22 | import com.baidu.mapapi.map.BaiduMap;
23 | import com.baidu.mapapi.map.BaiduMap.OnMapStatusChangeListener;
24 | import com.baidu.mapapi.map.BitmapDescriptor;
25 | import com.baidu.mapapi.map.BitmapDescriptorFactory;
26 | import com.baidu.mapapi.map.MapStatus;
27 | import com.baidu.mapapi.map.MapStatusUpdate;
28 | import com.baidu.mapapi.map.MapStatusUpdateFactory;
29 | import com.baidu.mapapi.map.MapView;
30 | import com.baidu.mapapi.map.MarkerOptions;
31 | import com.baidu.mapapi.map.MyLocationConfiguration;
32 | import com.baidu.mapapi.map.MyLocationConfiguration.LocationMode;
33 | import com.baidu.mapapi.map.MyLocationData;
34 | import com.baidu.mapapi.model.LatLng;
35 | import com.baidu.mapapi.search.core.PoiInfo;
36 | import com.baidu.mapapi.search.core.SearchResult;
37 | import com.baidu.mapapi.search.geocode.GeoCodeResult;
38 | import com.baidu.mapapi.search.geocode.GeoCoder;
39 | import com.baidu.mapapi.search.geocode.OnGetGeoCoderResultListener;
40 | import com.baidu.mapapi.search.geocode.ReverseGeoCodeOption;
41 | import com.baidu.mapapi.search.geocode.ReverseGeoCodeResult;
42 | import com.baidu.mapapi.search.poi.OnGetPoiSearchResultListener;
43 | import com.baidu.mapapi.search.poi.PoiCitySearchOption;
44 | import com.baidu.mapapi.search.poi.PoiDetailResult;
45 | import com.baidu.mapapi.search.poi.PoiResult;
46 | import com.baidu.mapapi.search.poi.PoiSearch;
47 | import com.gu.test.R;
48 | import com.gu.test.adapter.NearAddressAdapter;
49 | import com.gu.test.adapter.SearchAddressAdapter;
50 |
51 | import java.util.ArrayList;
52 | import java.util.List;
53 |
54 | import butterknife.ButterKnife;
55 | import butterknife.InjectView;
56 | import butterknife.OnClick;
57 |
58 | /**
59 | * @author Nate
60 | * @desc 服务地点选择界面
61 | * @date 2015-12-20
62 | */
63 | public class LocationActivity extends AppCompatActivity
64 | implements OnGetGeoCoderResultListener, OnGetPoiSearchResultListener {
65 |
66 | @InjectView(R.id.mapView)
67 | MapView mMapView;
68 | @InjectView(R.id.near_list_empty_ll)
69 | LinearLayout near_list_empty_ll;
70 | @InjectView(R.id.near_address_list)
71 | ListView near_address_list;
72 | @InjectView(R.id.search_address_list_view)
73 | ListView search_address_list_view;
74 | @InjectView(R.id.search_et)
75 | EditText search_et;
76 | @InjectView(R.id.search_empty_tv)
77 | TextView search_empty_tv;
78 | @InjectView(R.id.search_ll)
79 | LinearLayout search_ll;
80 | private GeoCoder mSearch = null; // 搜索模块,也可去掉地图模块独立使用
81 | private BaiduMap mBaiduMap = null;
82 | private MyLocationListenner myListener = new MyLocationListenner();
83 | private LocationMode mCurrentMode;
84 | private boolean isFirstLoc = true;// 是否首次定位
85 | private BitmapDescriptor mCurrentMarker;
86 | private LocationClient mLocClient;// 定位相关
87 | private PoiSearch mPoiSearch = null;
88 | private String cityName = "";
89 |
90 | private NearAddressAdapter nearAddressAdapter = null;
91 | private SearchAddressAdapter searchAddressAdapter = null;
92 | private List nearAddresses = new ArrayList();
93 | private List searchAddresses = new ArrayList();
94 |
95 |
96 | @Override
97 | protected void onCreate(@Nullable Bundle savedInstanceState) {
98 | super.onCreate(savedInstanceState);
99 | setContentView(R.layout.activity_service_location);
100 | ButterKnife.inject(this);
101 | initViewsAndEvents();
102 | }
103 |
104 | protected void initViewsAndEvents() {
105 | cityName = "南京";//这个可以通过定位获取
106 | // 隐藏比例尺和缩放图标
107 | mMapView.showScaleControl(false);
108 | mMapView.showZoomControls(false);
109 | mBaiduMap = mMapView.getMap();
110 | // 初始化搜索模块,注册事件监听
111 | mSearch = GeoCoder.newInstance();
112 | // 初始化搜索模块,注册搜索事件监听
113 | mPoiSearch = PoiSearch.newInstance();
114 | mPoiSearch.setOnGetPoiSearchResultListener(this);
115 | mSearch.setOnGetGeoCodeResultListener(this);
116 | mBaiduMap.setOnMapStatusChangeListener(new OnMapStatusChangeListener() {
117 |
118 | @Override
119 | public void onMapStatusChangeStart(MapStatus arg0) {
120 |
121 | }
122 |
123 | @Override
124 | public void onMapStatusChangeFinish(MapStatus arg0) {
125 | search_ll.setVisibility(View.GONE);
126 | mBaiduMap.clear();
127 | mBaiduMap.addOverlay(new MarkerOptions().position(arg0.target)
128 | .icon(mCurrentMarker));
129 | // 反Geo搜索
130 | mSearch.reverseGeoCode(new ReverseGeoCodeOption()
131 | .location(arg0.target));
132 | }
133 |
134 | @Override
135 | public void onMapStatusChange(MapStatus arg0) {
136 |
137 | }
138 | });
139 |
140 | search_et.addTextChangedListener(new TextWatcher() {
141 |
142 | @Override
143 | public void onTextChanged(CharSequence cs, int start, int before,
144 | int count) {
145 | if (cs == null || cs.length() <= 0) {
146 | search_ll.setVisibility(View.GONE);
147 | return;
148 | }
149 | /**
150 | * 使用建议搜索服务获取建议列表
151 | */
152 | mPoiSearch.searchInCity((new PoiCitySearchOption())
153 | .city(cityName).keyword(cs.toString()).pageNum(0)
154 | .pageCapacity(20));
155 | }
156 |
157 | @Override
158 | public void beforeTextChanged(CharSequence s, int start, int count,
159 | int after) {
160 |
161 | }
162 |
163 | @Override
164 | public void afterTextChanged(Editable s) {
165 |
166 | }
167 | });
168 |
169 | mCurrentMarker = BitmapDescriptorFactory
170 | .fromResource(R.mipmap.marker_icon);
171 | mCurrentMode = LocationMode.NORMAL;
172 | mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(
173 | mCurrentMode, true, mCurrentMarker));
174 | // 开启定位图层
175 | mBaiduMap.setMyLocationEnabled(false);
176 | // 定位初始化
177 | mLocClient = new LocationClient(this);
178 | // 设置地图缩放级别为15
179 | mBaiduMap.setMapStatus(MapStatusUpdateFactory
180 | .newMapStatus(new MapStatus.Builder().zoom(15).build()));
181 | mLocClient.registerLocationListener(myListener);
182 | LocationClientOption option = new LocationClientOption();
183 | option.setOpenGps(false);// 打开gpss
184 | option.setCoorType("bd09ll"); // 设置坐标类型 取值有3个: 返回国测局经纬度坐标系:gcj02
185 | // 返回百度墨卡托坐标系 :bd09 返回百度经纬度坐标系 :bd09ll
186 | option.setScanSpan(1000);// 扫描间隔 单位毫秒
187 | option.setLocationMode(LocationClientOption.LocationMode.Battery_Saving);
188 | mLocClient.setLocOption(option);
189 | mLocClient.start();
190 |
191 | nearAddressAdapter = new NearAddressAdapter(this,
192 | R.layout.item_near_address, nearAddresses);
193 | near_address_list.setAdapter(nearAddressAdapter);
194 | near_address_list.setEmptyView(near_list_empty_ll);
195 |
196 | near_address_list.setOnItemClickListener(new OnItemClickListener() {
197 |
198 | @Override
199 | public void onItemClick(AdapterView> parent, View view,
200 | int position, long id) {
201 | PoiInfo poiInfo = nearAddresses.get(position);
202 | Bundle bundle = new Bundle();
203 | bundle.putString("Ing", poiInfo.location.longitude + "");
204 | bundle.putString("Iat", poiInfo.location.latitude + "");
205 | bundle.putString("Address", poiInfo.name);
206 | bundle.putString("DetailedAddress", poiInfo.address);
207 | Intent intent = new Intent();
208 | intent.putExtras(bundle);
209 | setResult(RESULT_OK, intent);
210 | finish();
211 | }
212 | });
213 |
214 | searchAddressAdapter = new SearchAddressAdapter(this,
215 | R.layout.item_search_address, searchAddresses);
216 | search_address_list_view.setAdapter(searchAddressAdapter);
217 | search_address_list_view.setEmptyView(search_empty_tv);
218 |
219 | search_address_list_view
220 | .setOnItemClickListener(new OnItemClickListener() {
221 |
222 | @Override
223 | public void onItemClick(AdapterView> parent, View view,
224 | int position, long id) {
225 | PoiInfo poiInfo = searchAddresses.get(position);
226 | Bundle bundle = new Bundle();
227 | bundle.putString("Ing", poiInfo.location.longitude + "");
228 | bundle.putString("Iat", poiInfo.location.latitude + "");
229 | bundle.putString("Address", poiInfo.name);
230 | bundle.putString("DetailedAddress", poiInfo.address);
231 | Intent intent = new Intent();
232 | intent.putExtras(bundle);
233 | setResult(RESULT_OK, intent);
234 | finish();
235 | }
236 | });
237 | }
238 |
239 | @Override
240 | protected void onPause() {
241 | mMapView.onPause();
242 | super.onPause();
243 | }
244 |
245 | @Override
246 | protected void onResume() {
247 | mMapView.onResume();
248 | super.onResume();
249 | }
250 |
251 | @Override
252 | protected void onDestroy() {
253 | mMapView.onDestroy();
254 | mSearch.destroy();
255 | // 退出时销毁定位
256 | mLocClient.stop();
257 | // 关闭定位图层
258 | mBaiduMap.setMyLocationEnabled(false);
259 | mMapView = null;
260 | super.onDestroy();
261 | }
262 |
263 | @Override
264 | public void onGetGeoCodeResult(GeoCodeResult arg0) {
265 |
266 | }
267 |
268 | @Override
269 | public void onGetReverseGeoCodeResult(ReverseGeoCodeResult result) {
270 | if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
271 | Toast.makeText(LocationActivity.this, "抱歉,未能找到结果",
272 | Toast.LENGTH_LONG).show();
273 | return;
274 | }
275 |
276 | List list = result.getPoiList();
277 | if (list != null && list.size() > 0) {
278 | nearAddresses.clear();
279 | nearAddresses.addAll(list);
280 | nearAddressAdapter.notifyDataSetChanged();
281 | }
282 |
283 | }
284 |
285 | // 定位图标点击,重新设置为初次定位
286 | @OnClick(value = R.id.location_iv)
287 | public void reLocation(View view) {
288 | Toast.makeText(LocationActivity.this, "正在定位中...", Toast.LENGTH_SHORT).show();
289 | isFirstLoc = true;
290 | }
291 |
292 | /**
293 | * 定位SDK监听函数
294 | */
295 | public class MyLocationListenner implements BDLocationListener {
296 |
297 | @Override
298 | public void onReceiveLocation(BDLocation location) {
299 | // map view 销毁后不在处理新接收的位置
300 | if (location == null || mMapView == null) {
301 | return;
302 | }
303 | MyLocationData locData = new MyLocationData.Builder()
304 | .accuracy(location.getRadius())
305 | // 此处设置开发者获取到的方向信息,顺时针0-360
306 | .latitude(location.getLatitude())
307 | .longitude(location.getLongitude()).build();
308 | mBaiduMap.setMyLocationData(locData);
309 |
310 | cityName = location.getCity();
311 |
312 | if (isFirstLoc) {
313 | isFirstLoc = false;
314 | LatLng ll = new LatLng(location.getLatitude(),
315 | location.getLongitude());
316 | MapStatusUpdate mapStatusUpdate = MapStatusUpdateFactory
317 | .newLatLng(ll);
318 | mBaiduMap.animateMapStatus(mapStatusUpdate);
319 | }
320 | }
321 |
322 | public void onReceivePoi(BDLocation poiLocation) {
323 | }
324 | }
325 |
326 | @Override
327 | public void onGetPoiDetailResult(PoiDetailResult arg0) {
328 |
329 | }
330 |
331 | @Override
332 | public void onGetPoiResult(PoiResult result) {
333 | if (result == null
334 | || result.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) {
335 | return;
336 | }
337 | if (result.error == SearchResult.ERRORNO.NO_ERROR) {
338 | List list = result.getAllPoi();
339 | search_ll.setVisibility(View.VISIBLE);
340 | if (list != null && list.size() > 0) {
341 | searchAddresses.clear();
342 | searchAddresses.addAll(list);
343 | searchAddressAdapter.notifyDataSetChanged();
344 | }
345 | }
346 | }
347 |
348 | }
349 |
--------------------------------------------------------------------------------