├── app
├── .gitignore
├── keystore
│ └── mapdemo.jks
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_test.xml
│ │ │ │ └── activity_main.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── java
│ │ │ └── cn
│ │ │ │ └── lp
│ │ │ │ └── mapdemo
│ │ │ │ ├── MyApp.java
│ │ │ │ ├── testActivity.java
│ │ │ │ └── MainActivity.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── cn
│ │ │ └── lp
│ │ │ └── mapdemo
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── cn
│ │ └── lp
│ │ └── mapdemo
│ │ └── ExampleInstrumentedTest.java
├── signing.properties
├── proguard-rules.pro
├── build.gradle
└── app.iml
├── maplibrary
├── .gitignore
├── libs
│ └── BaiduLBS_Android.jar
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ └── strings.xml
│ │ │ ├── drawable
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── express_icon_location_centre_point.png
│ │ │ └── layout
│ │ │ │ ├── activity_gd_map.xml
│ │ │ │ ├── activity_bd_map.xml
│ │ │ │ ├── activity_bd2_map.xml
│ │ │ │ └── activity_gd_map_enclosure.xml
│ │ ├── jniLibs
│ │ │ ├── x86
│ │ │ │ ├── liblocSDK7b.so
│ │ │ │ ├── libBaiduMapSDK_map_v5_2_0.so
│ │ │ │ └── libBaiduMapSDK_base_v5_2_0.so
│ │ │ ├── armeabi
│ │ │ │ ├── liblocSDK7b.so
│ │ │ │ ├── libBaiduMapSDK_base_v5_2_0.so
│ │ │ │ └── libBaiduMapSDK_map_v5_2_0.so
│ │ │ └── armeabi-v7a
│ │ │ │ ├── liblocSDK7b.so
│ │ │ │ ├── libBaiduMapSDK_map_v5_2_0.so
│ │ │ │ └── libBaiduMapSDK_base_v5_2_0.so
│ │ ├── java
│ │ │ └── cn
│ │ │ │ └── lp
│ │ │ │ └── maplibrary
│ │ │ │ ├── test.java
│ │ │ │ ├── Bd2MapActivity.kt
│ │ │ │ ├── BdMapActivity.kt
│ │ │ │ ├── GdMapEnclosureActivity.kt
│ │ │ │ └── GdMapActivity.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── cn
│ │ │ └── lp
│ │ │ └── maplibrary
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── cn
│ │ └── lp
│ │ └── maplibrary
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
├── build.gradle
└── maplibrary.iml
├── .gradle
├── 4.4
│ ├── fileChanges
│ │ └── last-build.bin
│ ├── fileHashes
│ │ ├── fileHashes.bin
│ │ ├── fileHashes.lock
│ │ └── resourceHashesCache.bin
│ ├── javaCompile
│ │ ├── taskJars.bin
│ │ ├── jarAnalysis.bin
│ │ ├── javaCompile.lock
│ │ ├── taskHistory.bin
│ │ └── classAnalysis.bin
│ ├── fileContent
│ │ └── fileContent.lock
│ └── taskHistory
│ │ ├── taskHistory.bin
│ │ └── taskHistory.lock
└── buildOutputCleanup
│ ├── cache.properties
│ ├── outputFiles.bin
│ └── buildOutputCleanup.lock
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── README.md
├── .idea
├── caches
│ └── build_file_checksums.ser
├── vcs.xml
├── kotlinc.xml
├── libraries
│ ├── Gradle__com_google_code_findbugs_jsr305_2_0_1_jar.xml
│ ├── Gradle____local_aars___D__myXm_Express_mapdemo_maplibrary_libs_BaiduLBS_Android_jar_unspecified_jar.xml
│ ├── Gradle__com_android_support_constraint_constraint_layout_solver_1_1_3_jar.xml
│ ├── Gradle__com_amap_api_map2d_5_2_0_jar.xml
│ ├── Gradle__net_sf_kxml_kxml2_2_3_0_jar.xml
│ ├── Gradle__com_android_support_constraint_constraint_layout_1_1_3.xml
│ ├── Gradle__com_amap_api_location_4_2_0_jar.xml
│ ├── Gradle__android_arch_core_common_1_1_0_jar.xml
│ ├── Gradle__org_jetbrains_annotations_13_0_jar.xml
│ ├── Gradle__android_arch_lifecycle_common_1_1_0_jar.xml
│ ├── Gradle__com_android_support_support_annotations_27_1_1_jar.xml
│ ├── Gradle__android_arch_core_runtime_1_1_0.xml
│ ├── Gradle__junit_junit_4_12_jar.xml
│ ├── Gradle__android_arch_lifecycle_runtime_1_1_0.xml
│ ├── Gradle__com_android_support_test_runner_1_0_2.xml
│ ├── Gradle__com_android_support_test_monitor_1_0_2.xml
│ ├── Gradle__android_arch_lifecycle_viewmodel_1_1_0.xml
│ ├── Gradle__com_android_support_appcompat_v7_27_1_1.xml
│ ├── Gradle__android_arch_lifecycle_livedata_core_1_1_0.xml
│ ├── Gradle__com_android_support_support_compat_27_1_1.xml
│ ├── Gradle__com_android_support_support_core_ui_27_1_1.xml
│ ├── Gradle__com_android_support_support_fragment_27_1_1.xml
│ ├── Gradle__javax_inject_javax_inject_1_jar.xml
│ ├── Gradle__com_android_support_support_core_utils_27_1_1.xml
│ ├── Gradle__com_android_support_test_espresso_espresso_core_3_0_2.xml
│ ├── Gradle__com_squareup_javawriter_2_1_1_jar.xml
│ ├── Gradle__org_hamcrest_hamcrest_core_1_3_jar.xml
│ ├── Gradle__com_android_support_support_vector_drawable_27_1_1.xml
│ ├── Gradle__com_android_support_animated_vector_drawable_27_1_1.xml
│ ├── Gradle__org_hamcrest_hamcrest_library_1_3_jar.xml
│ ├── Gradle__com_android_support_test_espresso_espresso_idling_resource_3_0_2.xml
│ ├── Gradle__org_hamcrest_hamcrest_integration_1_3_jar.xml
│ ├── Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_1_2_4_jar.xml
│ └── Gradle__org_jetbrains_kotlin_kotlin_stdlib_jre7_1_1_2_4_jar.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
├── misc.xml
└── codeStyles
│ └── Project.xml
├── local.properties
├── gradle.properties
├── mapdemo.iml
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/maplibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/.gradle/4.4/fileChanges/last-build.bin:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':maplibrary'
2 |
--------------------------------------------------------------------------------
/.gradle/buildOutputCleanup/cache.properties:
--------------------------------------------------------------------------------
1 | #Fri Sep 07 09:05:19 CST 2018
2 | gradle.version=4.4
3 |
--------------------------------------------------------------------------------
/app/keystore/mapdemo.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/app/keystore/mapdemo.jks
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | mapdemo
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # mapdemo
2 | 百度地图、高德地图部分功能的实现:
3 | 地图基础功能、
4 | 定位功能、
5 | 锚点绘制、
6 | 轨迹绘制、
7 | 电子围栏绘制。
8 | 本项目为地图功能探索的技术交流
9 |
--------------------------------------------------------------------------------
/.gradle/4.4/fileHashes/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/.gradle/4.4/fileHashes/fileHashes.bin
--------------------------------------------------------------------------------
/.gradle/4.4/fileHashes/fileHashes.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/.gradle/4.4/fileHashes/fileHashes.lock
--------------------------------------------------------------------------------
/.gradle/4.4/javaCompile/taskJars.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/.gradle/4.4/javaCompile/taskJars.bin
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/maplibrary/libs/BaiduLBS_Android.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/maplibrary/libs/BaiduLBS_Android.jar
--------------------------------------------------------------------------------
/maplibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | mapLibrary
3 |
4 |
--------------------------------------------------------------------------------
/.gradle/4.4/fileContent/fileContent.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/.gradle/4.4/fileContent/fileContent.lock
--------------------------------------------------------------------------------
/.gradle/4.4/javaCompile/jarAnalysis.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/.gradle/4.4/javaCompile/jarAnalysis.bin
--------------------------------------------------------------------------------
/.gradle/4.4/javaCompile/javaCompile.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/.gradle/4.4/javaCompile/javaCompile.lock
--------------------------------------------------------------------------------
/.gradle/4.4/javaCompile/taskHistory.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/.gradle/4.4/javaCompile/taskHistory.bin
--------------------------------------------------------------------------------
/.gradle/4.4/taskHistory/taskHistory.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/.gradle/4.4/taskHistory/taskHistory.bin
--------------------------------------------------------------------------------
/.gradle/4.4/taskHistory/taskHistory.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/.gradle/4.4/taskHistory/taskHistory.lock
--------------------------------------------------------------------------------
/.gradle/4.4/javaCompile/classAnalysis.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/.gradle/4.4/javaCompile/classAnalysis.bin
--------------------------------------------------------------------------------
/.gradle/buildOutputCleanup/outputFiles.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/.gradle/buildOutputCleanup/outputFiles.bin
--------------------------------------------------------------------------------
/app/signing.properties:
--------------------------------------------------------------------------------
1 | KEYSTORE_FILE = ./keystore/mapdemo.jks
2 | KEYSTORE_PASSWORD = map123456
3 | KEY_ALIAS = map
4 | KEY_PASSWORD = map123456
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gradle/4.4/fileHashes/resourceHashesCache.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/.gradle/4.4/fileHashes/resourceHashesCache.bin
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/maplibrary/src/main/jniLibs/x86/liblocSDK7b.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/maplibrary/src/main/jniLibs/x86/liblocSDK7b.so
--------------------------------------------------------------------------------
/.gradle/buildOutputCleanup/buildOutputCleanup.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/.gradle/buildOutputCleanup/buildOutputCleanup.lock
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/maplibrary/src/main/jniLibs/armeabi/liblocSDK7b.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/maplibrary/src/main/jniLibs/armeabi/liblocSDK7b.so
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/maplibrary/src/main/jniLibs/armeabi-v7a/liblocSDK7b.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/maplibrary/src/main/jniLibs/armeabi-v7a/liblocSDK7b.so
--------------------------------------------------------------------------------
/maplibrary/src/main/res/drawable/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/maplibrary/src/main/res/drawable/ic_launcher_round.png
--------------------------------------------------------------------------------
/maplibrary/src/main/jniLibs/x86/libBaiduMapSDK_map_v5_2_0.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/maplibrary/src/main/jniLibs/x86/libBaiduMapSDK_map_v5_2_0.so
--------------------------------------------------------------------------------
/maplibrary/src/main/jniLibs/x86/libBaiduMapSDK_base_v5_2_0.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/maplibrary/src/main/jniLibs/x86/libBaiduMapSDK_base_v5_2_0.so
--------------------------------------------------------------------------------
/maplibrary/src/main/jniLibs/armeabi/libBaiduMapSDK_base_v5_2_0.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/maplibrary/src/main/jniLibs/armeabi/libBaiduMapSDK_base_v5_2_0.so
--------------------------------------------------------------------------------
/maplibrary/src/main/jniLibs/armeabi/libBaiduMapSDK_map_v5_2_0.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/maplibrary/src/main/jniLibs/armeabi/libBaiduMapSDK_map_v5_2_0.so
--------------------------------------------------------------------------------
/maplibrary/src/main/jniLibs/armeabi-v7a/libBaiduMapSDK_map_v5_2_0.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/maplibrary/src/main/jniLibs/armeabi-v7a/libBaiduMapSDK_map_v5_2_0.so
--------------------------------------------------------------------------------
/maplibrary/src/main/jniLibs/armeabi-v7a/libBaiduMapSDK_base_v5_2_0.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/maplibrary/src/main/jniLibs/armeabi-v7a/libBaiduMapSDK_base_v5_2_0.so
--------------------------------------------------------------------------------
/maplibrary/src/main/res/drawable/express_icon_location_centre_point.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupertoL/mapdemo/HEAD/maplibrary/src/main/res/drawable/express_icon_location_centre_point.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/lp/mapdemo/MyApp.java:
--------------------------------------------------------------------------------
1 | package cn.lp.mapdemo;
2 |
3 | import android.app.Application;
4 |
5 | public class MyApp extends Application {
6 |
7 |
8 |
9 | @Override
10 | public void onCreate() {
11 | super.onCreate();
12 | }
13 |
14 |
15 |
16 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Sep 07 09:04:42 CST 2018
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-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle____local_aars___D__myXm_Express_mapdemo_maplibrary_libs_BaiduLBS_Android_jar_unspecified_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file must *NOT* be checked into Version Control Systems,
2 | # as it contains information specific to your local configuration.
3 | #
4 | # Location of the SDK. This is only used by Gradle.
5 | # For customization when using a Version Control System, please read the
6 | # header note.
7 | #Fri Sep 07 09:04:42 CST 2018
8 | ndk.dir=D\:\\developTools\\Android\\Local\\Android\\sdk\\ndk-bundle
9 | sdk.dir=D\:\\developTools\\Android\\Local\\Android\\sdk
10 |
--------------------------------------------------------------------------------
/app/src/test/java/cn/lp/mapdemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package cn.lp.mapdemo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/maplibrary/src/test/java/cn/lp/maplibrary/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package cn.lp.maplibrary;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_android_support_constraint_constraint_layout_solver_1_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/maplibrary/src/main/java/cn/lp/maplibrary/test.java:
--------------------------------------------------------------------------------
1 | package cn.lp.maplibrary;
2 |
3 | import android.view.View;
4 | import android.widget.TextView;
5 |
6 | import com.amap.api.maps2d.model.MarkerOptions;
7 | import com.baidu.mapapi.map.InfoWindow;
8 |
9 | import cn.shequren.map.R;
10 |
11 | /**
12 | * @author Loren
13 | * Create_Time: 2018/9/7 14:00
14 | * description:
15 | */
16 | public class test {
17 |
18 | MarkerOptions markerOptions =new MarkerOptions();
19 | private void a(){
20 |
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_amap_api_map2d_5_2_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__net_sf_kxml_kxml2_2_3_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_android_support_constraint_constraint_layout_1_1_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_amap_api_location_4_2_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__android_arch_core_common_1_1_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_jetbrains_annotations_13_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__android_arch_lifecycle_common_1_1_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_test.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_android_support_support_annotations_27_1_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__android_arch_core_runtime_1_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__junit_junit_4_12_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__android_arch_lifecycle_runtime_1_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_android_support_test_runner_1_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_android_support_test_monitor_1_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__android_arch_lifecycle_viewmodel_1_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_android_support_appcompat_v7_27_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__android_arch_lifecycle_livedata_core_1_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_android_support_support_compat_27_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_android_support_support_core_ui_27_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_android_support_support_fragment_27_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__javax_inject_javax_inject_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_android_support_support_core_utils_27_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | android.useDeprecatedNdk=true
--------------------------------------------------------------------------------
/app/src/main/java/cn/lp/mapdemo/testActivity.java:
--------------------------------------------------------------------------------
1 | package cn.lp.mapdemo;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 |
8 | import cn.lp.maplibrary.GdMapActivity;
9 |
10 | public class testActivity extends AppCompatActivity {
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_test);
16 |
17 | findViewById(R.id.btn_test).setOnClickListener(new View.OnClickListener() {
18 | @Override
19 | public void onClick(View v) {
20 |
21 | }
22 | });
23 |
24 | startActivity( new Intent(this,GdMapActivity.class));
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_android_support_test_espresso_espresso_core_3_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_android_support_support_vector_drawable_27_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_android_support_animated_vector_drawable_27_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/maplibrary/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/cn/lp/mapdemo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package cn.lp.mapdemo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("cn.lp.mapdemo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_android_support_test_espresso_espresso_idling_resource_3_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_1_2_4_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/maplibrary/src/androidTest/java/cn/lp/maplibrary/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package cn.lp.maplibrary;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("cn.lp.maplibrary.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/mapdemo.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jre7_1_1_2_4_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/maplibrary/src/main/res/layout/activity_gd_map.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
19 |
20 |
27 |
28 |
35 |
--------------------------------------------------------------------------------
/maplibrary/src/main/res/layout/activity_bd_map.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
19 |
20 |
27 |
28 |
35 |
--------------------------------------------------------------------------------
/maplibrary/src/main/res/layout/activity_bd2_map.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
19 |
20 |
27 |
28 |
35 |
--------------------------------------------------------------------------------
/maplibrary/src/main/res/layout/activity_gd_map_enclosure.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
19 |
20 |
27 |
28 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/lp/mapdemo/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package cn.lp.mapdemo
2 |
3 | import android.content.Intent
4 | import android.os.Bundle
5 | import android.support.v7.app.AppCompatActivity
6 | import cn.lp.maplibrary.Bd2MapActivity
7 | import cn.lp.maplibrary.BdMapActivity
8 | import cn.lp.maplibrary.GdMap2Activity
9 | import cn.lp.maplibrary.GdMapActivity
10 | import kotlinx.android.synthetic.main.activity_main.*
11 |
12 | class MainActivity : AppCompatActivity() {
13 |
14 | override fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 | setContentView(R.layout.activity_main)
17 |
18 | btn_gd.setOnClickListener {
19 | startActivity(Intent(this, GdMapActivity::class.java))
20 | }
21 | btn_gd_map2.setOnClickListener {
22 | startActivity(Intent(this, GdMap2Activity::class.java))
23 | }
24 |
25 | btn_bd.setOnClickListener {
26 | startActivity(Intent(this, BdMapActivity::class.java))
27 | }
28 | btn_bd2.setOnClickListener {
29 | startActivity(Intent(this, Bd2MapActivity::class.java))
30 | }
31 |
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
18 |
19 |
25 |
31 |
37 |
--------------------------------------------------------------------------------
/maplibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | android {
5 | compileSdkVersion 27
6 |
7 |
8 |
9 | defaultConfig {
10 | minSdkVersion 14
11 | targetSdkVersion 27
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 |
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | }
27 |
28 | dependencies {
29 | implementation fileTree(dir: 'libs', include: ['*.jar'])
30 |
31 | api 'com.android.support:appcompat-v7:27.1.1'
32 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
33 | testImplementation 'junit:junit:4.12'
34 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
35 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
36 | api "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.2-4"
37 | implementation 'com.amap.api:map2d:5.2.0'
38 | implementation 'com.amap.api:location:4.2.0'
39 | }
40 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | android {
5 | compileSdkVersion 27
6 | defaultConfig {
7 | applicationId "cn.lp.mapdemo"
8 | minSdkVersion 14
9 | targetSdkVersion 27
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 |
14 | ndk {
15 | //设置支持的SO库架构
16 | abiFilters 'armeabi', 'armeabi-v7a', 'x86'
17 | }
18 | }
19 | Properties props = new Properties()
20 | props.load(new FileInputStream(file("signing.properties")))
21 | signingConfigs {
22 | release {
23 | keyAlias props['KEY_ALIAS']
24 | keyPassword props['KEY_PASSWORD']
25 | storeFile file(props['KEYSTORE_FILE'])
26 | storePassword props['KEYSTORE_PASSWORD']
27 | }
28 | }
29 |
30 |
31 | buildTypes {
32 | debug {
33 | zipAlignEnabled true //ZipAlign优化
34 | signingConfig signingConfigs.release
35 | }
36 |
37 | release {
38 | zipAlignEnabled true
39 | signingConfig signingConfigs.release
40 | }
41 | }
42 |
43 |
44 | sourceSets {
45 | main {
46 | jniLibs.srcDir 'libs'
47 | //说明so的路径为该libs路径,关联所有地图SDK的so文件
48 | }
49 | }
50 | }
51 |
52 | dependencies {
53 | implementation fileTree(dir: 'libs', include: ['*.jar'])
54 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
55 | testImplementation 'junit:junit:4.12'
56 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
57 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
58 |
59 | implementation project(':maplibrary')
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/maplibrary/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 |
31 |
32 |
34 |
35 |
36 |
37 |
38 |
39 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/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 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
16 |
21 |
26 |
31 |
36 |
41 |
46 |
51 |
56 |
61 |
66 |
71 |
76 |
81 |
86 |
91 |
96 |
101 |
106 |
111 |
116 |
121 |
126 |
131 |
136 |
141 |
146 |
151 |
156 |
161 |
166 |
171 |
172 |
--------------------------------------------------------------------------------
/maplibrary/src/main/java/cn/lp/maplibrary/Bd2MapActivity.kt:
--------------------------------------------------------------------------------
1 | package cn.lp.maplibrary
2 |
3 | import android.graphics.Color
4 | import android.os.Bundle
5 | import android.support.v7.app.AppCompatActivity
6 | import android.widget.Toast
7 | import cn.shequren.map.R
8 | import com.baidu.location.BDAbstractLocationListener
9 | import com.baidu.location.BDLocation
10 | import com.baidu.location.LocationClient
11 | import com.baidu.location.LocationClientOption
12 | import com.baidu.mapapi.SDKInitializer
13 | import com.baidu.mapapi.map.*
14 | import com.baidu.mapapi.model.LatLng
15 | import kotlinx.android.synthetic.main.activity_bd2_map.*
16 |
17 | class Bd2MapActivity : AppCompatActivity() {
18 |
19 |
20 | lateinit var mBaiduMap: BaiduMap
21 | lateinit var mLocationClient: LocationClient
22 | var latLng: LatLng? = null
23 | var iseDitMode: Boolean = false
24 |
25 | var latLngs = arrayListOf();
26 | var bdPolyline: Overlay? = null
27 | var mPolylineOptions = PolylineOptions()
28 | var bdStartMarker1: Overlay? = null
29 | var bdStartMarker2: Overlay? = null
30 |
31 |
32 | /**
33 | * 临时存放围栏
34 | */
35 | var bdPolygonOptions = arrayListOf()
36 |
37 | /**
38 | * 围栏绘制的引用对象
39 | */
40 | var bdDrawPolylineOptionsOverlayList = arrayListOf()
41 |
42 | override fun onCreate(savedInstanceState: Bundle?) {
43 | super.onCreate(savedInstanceState)
44 | SDKInitializer.initialize(getApplicationContext());
45 | setContentView(R.layout.activity_bd2_map)
46 |
47 |
48 |
49 | intMap()
50 | intiView()
51 | }
52 |
53 | private fun intiView() {
54 |
55 | //修改地图模式
56 | type.setOnClickListener {
57 |
58 | if (mBaiduMap.mapType == BaiduMap.MAP_TYPE_NORMAL) {
59 | mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
60 | } else {
61 | mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
62 | }
63 |
64 | }
65 | around.setOnClickListener {
66 | if (around.text.equals("保存")) {
67 | savPolygonOptions()
68 | }
69 | iseDitMode = !iseDitMode;
70 | if (iseDitMode) {
71 | latLngs.clear()
72 |
73 | if (mPolylineOptions.points != null && mPolylineOptions.points.size > 1) {
74 | mPolylineOptions.points.clear()
75 | }
76 |
77 | around.setText("保存")
78 | } else {
79 | around.setText("添加")
80 | }
81 | trajectory.setText("显示围栏")
82 | closAllPolygonOptions()
83 |
84 | }
85 | trajectory.setOnClickListener {
86 |
87 | if (trajectory.text.equals("显示围栏")) {
88 | trajectory.setText("关闭围栏")
89 | showPolygonOptions()
90 | } else {
91 | trajectory.setText("显示围栏")
92 | closAllPolygonOptions()
93 | }
94 | }
95 | }
96 |
97 |
98 | private fun intMap() {
99 | mBaiduMap = bd_mapView.map;
100 |
101 | //设置地图的模式
102 | mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
103 |
104 | //开启定位图层
105 | mBaiduMap.setMyLocationEnabled(true);
106 | //设置地图的缩放级别
107 | mBaiduMap.setMapStatus(MapStatusUpdateFactory.zoomTo(16f));
108 |
109 | mLocationClient = LocationClient(getApplicationContext()); //声明LocationClient类
110 | /**
111 | * 设置地图允许所有的手势操作,根据需要可以去设置那些打开那些关闭
112 | * 使用的类为:java.lang.Object
113 | * com.baidu.mapapi.map.UiSettings
114 | * 参考Api:http://wiki.lbsyun.baidu.com/cms/androidsdk/doc/v5.2.0/index.html
115 | */
116 | mBaiduMap.uiSettings.setAllGesturesEnabled(true)
117 | //注册监听函数
118 | var myLocationListener = MyLocation2Listener()
119 | initLocation()
120 | mLocationClient.registerLocationListener(myLocationListener);
121 | //开启定位
122 | mLocationClient.start();
123 | //图片点击事件,回到定位点
124 | mLocationClient.requestLocation();
125 | }
126 |
127 | //配置定位SDK参数
128 | private fun initLocation() {
129 | val option = LocationClientOption()
130 | option.locationMode = LocationClientOption.LocationMode.Hight_Accuracy//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
131 | option.setCoorType("bd09ll")//可选,默认gcj02,设置返回的定位结果坐标系
132 | option.setScanSpan(1000)//可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
133 | option.setIsNeedAddress(true)//可选,设置是否需要地址信息,默认不需要
134 | option.isOpenGps = true//可选,默认false,设置是否使用gps
135 | option.isLocationNotify = true//可选,默认false,设置是否当GPS有效时按照1S/1次频率输出GPS结果
136 | option.setIsNeedLocationDescribe(true)//可选,默认false,设置是否需要位置语义化结果,可以在BDLocation
137 | // .getLocationDescribe里得到,结果类似于“在北京天安门附近”
138 | option.setIsNeedLocationPoiList(true)//可选,默认false,设置是否需要POI结果,可以在BDLocation.getPoiList里得到
139 | option.setIgnoreKillProcess(false)
140 | option.isOpenGps = true // 打开gps
141 |
142 | //可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认不杀死
143 | option.SetIgnoreCacheException(false)//可选,默认false,设置是否收集CRASH信息,默认收集
144 | option.setEnableSimulateGps(false)//可选,默认false,设置是否需要过滤GPS仿真结果,默认需要
145 | mLocationClient.locOption = option
146 |
147 | //用户点击地图回调
148 | mBaiduMap.setOnMapClickListener(object : BaiduMap.OnMapClickListener {
149 | override fun onMapClick(latLng: LatLng) {
150 |
151 | /**
152 | * 根据用户的点击绘制多边形的定点
153 | */
154 | if (iseDitMode) {
155 | latLngs.add(latLng)
156 | if (latLngs.size > 1) {
157 |
158 | if (bdPolyline != null) {
159 | bdPolyline!!.remove()
160 | }
161 | mPolylineOptions.points(latLngs).dottedLine(false).color(Color.argb(255, 255, 20, 147)).width(5)
162 | bdPolyline = mBaiduMap.addOverlay(mPolylineOptions);
163 | bdStartMarker1!!.remove()
164 | } else if (latLngs.size > 0) {
165 |
166 | var markerOption = MarkerOptions()
167 | markerOption.position(latLng).icon(BitmapDescriptorFactory.fromResource(R.drawable.express_icon_location_centre_point))
168 | bdStartMarker1 = mBaiduMap.addOverlay(markerOption)
169 | }
170 | }
171 |
172 | }
173 |
174 | override fun onMapPoiClick(mapPoi: MapPoi): Boolean {
175 | return false
176 | }
177 | })
178 | }
179 |
180 |
181 | override fun onResume() {
182 | super.onResume()
183 | this.bd_mapView.onResume()
184 | }
185 |
186 | override fun onPause() {
187 | super.onPause()
188 | this.bd_mapView.onPause()
189 | }
190 |
191 | override fun onDestroy() {
192 | super.onDestroy()
193 | bd_mapView.onDestroy();
194 | MapView.setMapCustomEnable(false);
195 | }
196 |
197 | //实现BDLocationListener接口,BDLocationListener为结果监听接口,异步获取定位结果
198 | inner class MyLocation2Listener : BDAbstractLocationListener() {
199 |
200 | override fun onReceiveLocation(location: BDLocation) {
201 |
202 | latLng = LatLng(location.latitude, location.longitude)
203 | setLocationData(latLng!!)
204 | }
205 |
206 | override fun onConnectHotSpotMessage(s: String?, i: Int) {
207 |
208 | }
209 | }
210 |
211 | private fun setLocationData(latLng: LatLng) {
212 |
213 | // 构造定位数据
214 | val locData = MyLocationData.Builder()
215 | // 此处设置开发者获取到的方向信息,顺时针0-360
216 | .direction(100f).latitude(latLng.latitude)
217 | .longitude(latLng.longitude).build()
218 | // 设置定位数据
219 | mBaiduMap.setMyLocationData(locData)
220 | val mapStatusUpdate = MapStatusUpdateFactory.newLatLng(latLng)
221 | mBaiduMap.animateMapStatus(mapStatusUpdate)
222 | //定义Maker坐标点
223 | }
224 |
225 | /**
226 | * 隐藏围栏对象
227 | */
228 | private fun closAllPolygonOptions() {
229 | for (overlay in bdDrawPolylineOptionsOverlayList) {
230 | overlay.setVisible(false)
231 | }
232 | }
233 |
234 | /**
235 | * 显示围栏对象(高德地图也可以使用该方式显示,)
236 | */
237 | private fun showPolygonOptions() {
238 | for (overlay in bdDrawPolylineOptionsOverlayList) {
239 | overlay.setVisible(true)
240 | }
241 |
242 | }
243 |
244 |
245 | /**
246 | * 根据定点生产多边形对象,及可以作为围栏对象
247 | * 通过com.baidu.mapapi.utils
248 | * SpatialRelationUtil
249 | * 可以判断经纬度是否在电子围栏中
250 | * isPolygonContainsPoint()可以判断对象点位是否在电子围栏中
251 | */
252 | private fun savPolygonOptions() {
253 | if (latLngs.size > 2) {
254 | //latLngs.add(latLngs.get(0))
255 | var latLng = arrayListOf()
256 | latLng = latLngs.clone() as ArrayList;
257 | var polygonOptions = PolygonOptions().points(latLngs).fillColor(Color.argb(150, 239, 113, 113))
258 | polygonOptions.visible(false)
259 | bdPolygonOptions.add(polygonOptions)
260 | bdDrawPolylineOptionsOverlayList.add(mBaiduMap.addOverlay(polygonOptions))
261 | if (bdPolyline != null) {
262 | bdPolyline!!.remove()
263 | }
264 | trajectory.setText("显示围栏")
265 |
266 | } else {
267 | Toast.makeText(this, "至少添加三个点才能建立围栏", Toast.LENGTH_LONG).show()
268 | }
269 | }
270 |
271 |
272 | }
273 |
--------------------------------------------------------------------------------
/maplibrary/src/main/java/cn/lp/maplibrary/BdMapActivity.kt:
--------------------------------------------------------------------------------
1 | package cn.lp.maplibrary
2 |
3 | import android.graphics.Color
4 | import android.os.Bundle
5 | import android.support.v7.app.AppCompatActivity
6 | import cn.shequren.map.R
7 | import cn.shequren.map.R.layout
8 | import com.baidu.location.BDAbstractLocationListener
9 | import com.baidu.location.BDLocation
10 | import com.baidu.location.LocationClient
11 | import com.baidu.location.LocationClientOption
12 | import com.baidu.mapapi.SDKInitializer
13 | import com.baidu.mapapi.map.*
14 | import com.baidu.mapapi.model.LatLng
15 | import kotlinx.android.synthetic.main.activity_bd_map.*
16 | import java.util.*
17 |
18 | /**
19 | * 百度地图显示、定位、轨迹绘制、Marker点绘制
20 | */
21 | class BdMapActivity : AppCompatActivity() {
22 |
23 |
24 | lateinit var mBaiduMap: BaiduMap
25 | lateinit var mLocationClient: LocationClient
26 | var latLng: LatLng? = null
27 | var bdPolyline: Overlay? = null
28 | var bdMarker = arrayListOf()
29 | override fun onCreate(savedInstanceState: Bundle?) {
30 | super.onCreate(savedInstanceState)
31 | /**
32 | * 地图使用前必须要调用初始化,并且要在setContentView()前
33 | */
34 | SDKInitializer.initialize(getApplicationContext());
35 | setContentView(layout.activity_bd_map)
36 |
37 | intMap()
38 | intiView()
39 | }
40 |
41 | private fun intiView() {
42 |
43 | //修改地图模式
44 | type.setOnClickListener {
45 |
46 | if (mBaiduMap.mapType == BaiduMap.MAP_TYPE_NORMAL) {
47 | mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
48 | } else {
49 | mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
50 | }
51 |
52 | }
53 |
54 | /**
55 | * 绘制锚点
56 | */
57 | around.setOnClickListener {
58 | setAroundInfor(this.latLng!!)
59 | }
60 | /**
61 | * 绘制轨迹
62 | */
63 | trajectory.setOnClickListener {
64 |
65 | trajectory(this.latLng!!);
66 | }
67 | }
68 |
69 | /**
70 | * 初始化地图对象
71 | */
72 | private fun intMap() {
73 |
74 | /**
75 | * 获取地图操作对象
76 | */
77 | mBaiduMap = bd_mapView.map;
78 |
79 | //设置地图的模式
80 | mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
81 |
82 | //开启定位图层
83 | mBaiduMap.setMyLocationEnabled(true);
84 | //设置地图的缩放级别
85 | mBaiduMap.setMapStatus(MapStatusUpdateFactory.zoomTo(16f));
86 |
87 |
88 | /**
89 | * 一下为定位的设置
90 | */
91 | mLocationClient = LocationClient(getApplicationContext()); //声明LocationClient类
92 | /**
93 | * 设置地图允许所有的手势操作,根据需要可以去设置那些打开那些关闭
94 | * 使用的类为:java.lang.Object
95 | * com.baidu.mapapi.map.UiSettings
96 | * 参考Api:http://wiki.lbsyun.baidu.com/cms/androidsdk/doc/v5.2.0/index.html
97 | */
98 | mBaiduMap.uiSettings.setAllGesturesEnabled(true)
99 | //注册监听函数
100 | var myLocationListener = MyLocationListener();
101 | initLocation()
102 | mLocationClient.registerLocationListener(myLocationListener);
103 | //开启定位
104 | mLocationClient.start();
105 | //图片点击事件,回到定位点
106 | mLocationClient.requestLocation();
107 | }
108 |
109 | //配置定位SDK参数
110 | private fun initLocation() {
111 | val option = LocationClientOption()
112 | option.locationMode = LocationClientOption.LocationMode.Hight_Accuracy//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
113 | option.setCoorType("bd09ll")//可选,默认gcj02,设置返回的定位结果坐标系
114 | option.setScanSpan(1000)//可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
115 | option.setIsNeedAddress(true)//可选,设置是否需要地址信息,默认不需要
116 | option.isOpenGps = true//可选,默认false,设置是否使用gps
117 | option.isLocationNotify = true//可选,默认false,设置是否当GPS有效时按照1S/1次频率输出GPS结果
118 | option.setIsNeedLocationDescribe(true)//可选,默认false,设置是否需要位置语义化结果,可以在BDLocation
119 | // .getLocationDescribe里得到,结果类似于“在北京天安门附近”
120 | option.setIsNeedLocationPoiList(true)//可选,默认false,设置是否需要POI结果,可以在BDLocation.getPoiList里得到
121 | option.setIgnoreKillProcess(false)
122 | option.isOpenGps = true // 打开gps
123 |
124 | //可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认不杀死
125 | option.SetIgnoreCacheException(false)//可选,默认false,设置是否收集CRASH信息,默认收集
126 | option.setEnableSimulateGps(false)//可选,默认false,设置是否需要过滤GPS仿真结果,默认需要
127 | mLocationClient.locOption = option
128 | }
129 |
130 |
131 | override fun onResume() {
132 | super.onResume()
133 | this.bd_mapView.onResume()
134 | }
135 |
136 | override fun onPause() {
137 | super.onPause()
138 | this.bd_mapView.onPause()
139 | }
140 |
141 | override fun onDestroy() {
142 | super.onDestroy()
143 | bd_mapView.onDestroy();
144 | MapView.setMapCustomEnable(false);
145 | }
146 |
147 | //实现BDLocationListener接口,BDLocationListener为结果监听接口,异步获取定位结果
148 | inner class MyLocationListener : BDAbstractLocationListener() {
149 |
150 | override fun onReceiveLocation(location: BDLocation) {
151 |
152 | latLng = LatLng(location.latitude, location.longitude)
153 | setLocationData(latLng!!)
154 | }
155 |
156 | override fun onConnectHotSpotMessage(s: String?, i: Int) {
157 |
158 | }
159 | }
160 |
161 |
162 | private fun setLocationData(latLng: LatLng) {
163 | // 设置定位数据
164 | mBaiduMap.setMyLocationData(MyLocationData.Builder()
165 | // 此处设置开发者获取到的方向信息,顺时针0-360
166 | .direction(100f).latitude(latLng.latitude)
167 | .longitude(latLng.longitude).build())
168 |
169 | mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLng(latLng))
170 |
171 | }
172 |
173 |
174 | /**
175 | * 周边
176 | */
177 | private fun setAroundInfor(latLng: LatLng) {
178 |
179 | /**
180 | * 真实开发中应该是一个Latlng的集合数据,这里就不用真实数据模拟20个点位数据
181 | */
182 | var lat: LatLng? = null
183 | var markerOptions = arrayListOf()
184 |
185 |
186 | for (i in 1..20) {
187 | var a = Random().nextDouble() * 0.001;
188 |
189 | if (i / 6 == 0) {
190 | lat = LatLng(latLng.latitude + a, latLng.longitude + 5 * a)
191 | } else if (i / 6 == 1) {
192 | lat = LatLng(latLng.latitude + 3 * a, latLng.longitude - a)
193 | } else if (i / 6 == 2) {
194 | lat = LatLng(latLng.latitude - 2 * a, latLng.longitude + 5 * a)
195 | } else if (i / 6 == 3) {
196 | lat = LatLng(latLng.latitude - 5 * a, latLng.longitude - a)
197 | } else if (i / 6 == 3) {
198 | lat = LatLng(latLng.latitude - 4 * a, latLng.longitude + 3 * a)
199 | } else if (i / 6 == 4) {
200 | lat = LatLng(latLng.latitude + 5 * a, latLng.longitude - 2 * a)
201 | } else if (i / 6 == 5) {
202 | lat = LatLng(latLng.latitude - a, latLng.longitude - 3 * a)
203 | }
204 |
205 | var markerOption = MarkerOptions()
206 | markerOption.position(lat).icon(BitmapDescriptorFactory.fromResource(R.drawable.express_icon_location_centre_point))
207 | markerOption.title("标题")
208 | var bundle = Bundle()
209 | bundle.putSerializable("info", "附加信息")
210 | markerOption.extraInfo(bundle)
211 | markerOptions.add(markerOption)
212 |
213 |
214 | }
215 |
216 | /**
217 | * 移除覆盖物
218 | */
219 | for (marker in bdMarker) {
220 | if (marker != null) {
221 | marker!!.remove()
222 | }
223 | }
224 | /**
225 | * 添加锚点覆盖物
226 | */
227 | bdMarker = mBaiduMap.addOverlays(markerOptions as List?) as ArrayList
228 | }
229 |
230 | private fun trajectory(latLng: LatLng) {
231 | /**
232 | * 真实开发中应该是一个Latlng的集合数据,这里就不用真实数据模拟20个点位数据
233 | */
234 |
235 |
236 | var lats = arrayListOf()
237 | var mPolylineOptions = PolylineOptions()
238 | var lat: LatLng? = null
239 |
240 | for (i in 1..20) {
241 | var a = Random().nextDouble() * 0.001;
242 | if (i / 6 == 0) {
243 | lat = LatLng(latLng.latitude + a, latLng.longitude + 5 * a)
244 | } else if (i / 6 == 1) {
245 | lat = LatLng(latLng.latitude + 3 * a, latLng.longitude - a)
246 | } else if (i / 6 == 2) {
247 | lat = LatLng(latLng.latitude - 2 * a, latLng.longitude + 5 * a)
248 | } else if (i / 6 == 3) {
249 | lat = LatLng(latLng.latitude - 5 * a, latLng.longitude - a)
250 | } else if (i / 6 == 3) {
251 | lat = LatLng(latLng.latitude - 4 * a, latLng.longitude + 3 * a)
252 | } else if (i / 6 == 4) {
253 | lat = LatLng(latLng.latitude + 5 * a, latLng.longitude - 2 * a)
254 | } else if (i / 6 == 5) {
255 | lat = LatLng(latLng.latitude - a, latLng.longitude - 3 * a)
256 | }
257 | if (lat != null) {
258 | lats.add(lat)
259 | }
260 | }
261 | if (bdPolyline != null) {
262 | bdPolyline!!.remove()
263 | }
264 | if (mPolylineOptions.points != null && mPolylineOptions.points.size > 0) {
265 | mPolylineOptions.points.clear()
266 | }
267 | mPolylineOptions.points(lats).dottedLine(false).color(Color.argb(255, 255, 20, 147)).width(5)
268 |
269 |
270 | /**
271 | * 绘制运动轨迹
272 | */
273 | bdPolyline = mBaiduMap.addOverlay(mPolylineOptions);
274 |
275 | }
276 |
277 | }
278 |
--------------------------------------------------------------------------------
/maplibrary/src/main/java/cn/lp/maplibrary/GdMapEnclosureActivity.kt:
--------------------------------------------------------------------------------
1 | package cn.lp.maplibrary
2 |
3 | import android.graphics.Color
4 | import android.os.Bundle
5 | import android.support.v7.app.AppCompatActivity
6 | import android.util.Log
7 | import android.widget.Toast
8 | import cn.shequren.map.R.layout
9 | import com.amap.api.location.AMapLocation
10 | import com.amap.api.location.AMapLocationClient
11 | import com.amap.api.location.AMapLocationClientOption
12 | import com.amap.api.location.AMapLocationListener
13 | import com.amap.api.maps2d.AMap
14 | import com.amap.api.maps2d.CameraUpdateFactory
15 | import com.amap.api.maps2d.LocationSource
16 | import com.amap.api.maps2d.model.*
17 | import kotlinx.android.synthetic.main.activity_gd_map_enclosure.*
18 |
19 | /**
20 | * 高德地图使用api绘制电子围栏
21 | * 使用到的定位和其他的知识这里不在重复详细注释
22 | */
23 | class GdMapEnclosureActivity : AppCompatActivity(), LocationSource, AMapLocationListener {
24 |
25 |
26 | lateinit var aMap: AMap
27 | var mListener: LocationSource.OnLocationChangedListener? = null
28 | var mlocationClient: AMapLocationClient? = null
29 | lateinit var mLocationOption: AMapLocationClientOption
30 |
31 | var mLatitude: Double = 0.0
32 | var mLongitude: Double = 0.0
33 |
34 | var iseDitMode = false;
35 | var latLngs = arrayListOf();
36 | var mPolygonOptions = arrayListOf();
37 | var mPolygons = arrayListOf();
38 | var markerOptions = MarkerOptions()
39 | var marker: Marker? = null
40 | var polylines = arrayListOf();
41 |
42 | override fun onLocationChanged(aMapLocation: AMapLocation?) {
43 | //定位成功
44 | if (mListener != null && aMapLocation != null) {
45 | if (aMapLocation.getErrorCode() == 0) {
46 |
47 | mListener!!.onLocationChanged(aMapLocation)// 显示系统小蓝点
48 | val latLng = LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude())
49 | mLatitude = aMapLocation.getLatitude()
50 | mLongitude = aMapLocation.getLongitude()
51 |
52 | setLocationSuccess(latLng)
53 |
54 | } else {
55 | val errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo()
56 | Log.e("AmapErr", errText)
57 | }
58 | }
59 | }
60 |
61 | override fun deactivate() {
62 | //定位停止
63 | mListener = null
64 | if (mlocationClient != null) {
65 | mlocationClient!!.stopLocation()
66 | mlocationClient!!.onDestroy()
67 | }
68 | mlocationClient = null
69 | }
70 |
71 | override fun activate(p0: LocationSource.OnLocationChangedListener?) {
72 | //定位
73 | mListener = p0!!
74 | if (null == mlocationClient) {
75 | mlocationClient = AMapLocationClient(this)
76 | mLocationOption = AMapLocationClientOption()
77 | // mLocationOption.setOnceLocation(true);
78 | mlocationClient!!.setLocationListener(this)
79 | //设置为高精度定位模式
80 | mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy)
81 |
82 | //定位间隔时间
83 | mLocationOption!!.setInterval(1000 * 2 * 60)
84 | //设置定位参数
85 | mlocationClient!!.setLocationOption(mLocationOption)
86 | // 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗,
87 | // 注意设置合适的定位时间的间隔(最小间隔支持为2000ms),并且在合适时间调用stopLocation()方法来取消定位请求
88 | // 在定位结束后,在合适的生命周期调用onDestroy()方法
89 | // 在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求,定位sdk内部会移除
90 |
91 | mlocationClient!!.startLocation()
92 | }
93 | }
94 |
95 |
96 | override fun onCreate(savedInstanceState: Bundle?) {
97 | super.onCreate(savedInstanceState)
98 | setContentView(layout.activity_gd_map_enclosure)
99 |
100 | mapView.onCreate(savedInstanceState)// 此方法必须重写
101 |
102 |
103 | intMap()
104 | intiView()
105 | }
106 |
107 | private fun intiView() {
108 |
109 | //修改地图模式
110 | type.setOnClickListener {
111 | if (aMap.mapType == AMap.MAP_TYPE_SATELLITE) {
112 | aMap.mapType = AMap.MAP_TYPE_NORMAL
113 | } else {
114 | aMap.mapType = AMap.MAP_TYPE_SATELLITE
115 | }
116 |
117 | }
118 | around.setOnClickListener {
119 |
120 |
121 | if (around.text.equals("保存")) {
122 | savPolygonOptions()
123 | }
124 |
125 | iseDitMode = !iseDitMode;
126 | if (iseDitMode) {
127 | latLngs.clear()
128 | polylines.clear()
129 | around.setText("保存")
130 | } else {
131 | around.setText("添加")
132 | }
133 | trajectory.setText("显示围栏")
134 | closAllPolygonOptions()
135 |
136 | }
137 | trajectory.setOnClickListener {
138 |
139 | if (trajectory.text.equals("显示围栏")) {
140 | trajectory.setText("关闭围栏")
141 | showPolygonOptions()
142 | } else {
143 | trajectory.setText("显示围栏")
144 | closAllPolygonOptions()
145 | }
146 | }
147 |
148 |
149 | }
150 |
151 | private fun intMap() {
152 | this.aMap = mapView.map
153 |
154 | this.aMap.isTrafficEnabled = true// 显示实时交通状况
155 | //地图模式可选类型:MAP_TYPE_NORMAL,MAP_TYPE_SATELLITE,MAP_TYPE_NIGHT
156 | this.aMap.mapType = AMap.MAP_TYPE_NORMAL// 卫星地图模式
157 |
158 | ///aMap.setOnMapClickListener(this) //点击地图监听
159 | aMap.setLocationSource(this)// 设置定位监听
160 | aMap.moveCamera(CameraUpdateFactory.zoomTo(16f))//设置缩放级别
161 | aMap.uiSettings.isMyLocationButtonEnabled = true// 设置默认定位按钮是否显示
162 |
163 | aMap.isMyLocationEnabled = true// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
164 | // 设置定位的类型为定位模式 ,可以由定位、跟随或地图根据面向方向旋转几种
165 | // aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCAT);
166 |
167 |
168 | aMap.moveCamera(CameraUpdateFactory.zoomTo(24f))
169 | //设置地图小蓝点
170 | val myLocationStyle = MyLocationStyle()
171 | myLocationStyle.myLocationIcon(BitmapDescriptorFactory
172 | .fromResource(Color.BLACK))// 设置小蓝点的图标
173 | myLocationStyle.strokeColor(Color.argb(0, 0, 0, 0))// 设置圆形的边框颜色
174 | myLocationStyle.radiusFillColor(Color.argb(150, 215, 238, 255))// 设置圆形的填充颜色
175 | // myLocationStyle.anchor(int,int)//设置小蓝点的锚点
176 | myLocationStyle.strokeWidth(2.0f)// 设置圆形的边框粗细
177 | aMap.setMyLocationStyle(myLocationStyle) // 将自定义的 myLocationStyle 对象添加到地图上
178 |
179 | aMap.setOnMapClickListener {
180 | /**
181 | * 根据用户在地图上的点击,绘制多边形的定点
182 | */
183 | if (iseDitMode) {
184 | latLngs.add(it)
185 | if (latLngs.size > 1) {
186 | //这里逻辑在运动轨迹文章中已经介绍
187 | var polyline = aMap.addPolyline(PolylineOptions()
188 | //手动数据测试
189 | //.add(new LatLng(26.57, 106.71),new LatLng(26.14,105.55),new LatLng(26.58, 104.82), new LatLng(30.67, 104.06))
190 | //集合数据
191 | .addAll(latLngs).width(4f).setDottedLine(false).geodesic(true)
192 | //颜色
193 | .color(Color.argb(255, 255, 68, 0)))
194 | polylines.add(polyline)
195 | this.marker!!.remove()
196 | } else {
197 | markerOptions.position(it)
198 | marker = aMap.addMarker(markerOptions);
199 | trajectory(it)
200 | }
201 | }
202 | }
203 | }
204 |
205 | override fun onResume() {
206 | super.onResume()
207 | this.mapView.onResume()
208 | }
209 |
210 | override fun onPause() {
211 | super.onPause()
212 | this.mapView.onPause()
213 | }
214 |
215 | override fun onDestroy() {
216 | super.onDestroy()
217 | this.mapView.onDestroy()
218 | }
219 |
220 | override fun onSaveInstanceState(outState: Bundle) {
221 | super.onSaveInstanceState(outState)
222 | //在activity执行onSaveInstanceState时执行mMapView.onSaveInstanceState (outState),保存地图当前的状态
223 | mapView.onSaveInstanceState(outState)
224 | }
225 |
226 |
227 | private fun setLocationSuccess(latLng: LatLng) {
228 | aMap.animateCamera(CameraUpdateFactory.changeLatLng(latLng))
229 |
230 | }
231 |
232 |
233 | private fun trajectory(latLng: LatLng) {
234 |
235 | polylines.add(aMap.addPolyline(PolylineOptions()
236 | //手动数据测试
237 | //.add(new LatLng(26.57, 106.71),new LatLng(26.14,105.55),new LatLng(26.58, 104.82), new LatLng(30.67, 104.06))
238 | //集合数据
239 | .add(latLng).width(4f).setDottedLine(false).geodesic(true)
240 | //颜色
241 | .color(Color.argb(255, 255, 68, 0))))
242 | aMap.invalidate()
243 | }
244 |
245 |
246 | /**
247 | * 根据多边形的定点绘制多边形,该对变形可作为电子围栏
248 | */
249 | private fun savPolygonOptions() {
250 | if (latLngs.size > 2) {
251 |
252 | latLngs.add(latLngs.get(0))
253 | mPolygonOptions.add(PolygonOptions().addAll(latLngs))
254 |
255 | /**
256 | * 移除绘制过程的定点覆盖物
257 | */
258 | for (polyline in polylines) {
259 | polyline.remove()
260 | }
261 | trajectory.setText("显示围栏")
262 | aMap.invalidate()
263 | } else {
264 | Toast.makeText(this, "至少添加三个点才能建立围栏", Toast.LENGTH_LONG).show()
265 | }
266 |
267 | }
268 |
269 | /**
270 | * 根据用户存储的多边形对象显示电子围栏
271 | * 通过aMap.addPolygon(polygonOptions)可以得到多边形对象
272 | * 通过polygon.contains(LatLng)可以判断出该Latlng对象是否在电子围栏中
273 | *
274 | */
275 | private fun showPolygonOptions() {
276 |
277 | for (polygonOptions in mPolygonOptions) {
278 | polygonOptions.fillColor(Color.argb(150, 239, 113, 113))
279 | .strokeColor(Color.argb(150, 239, 113, 113)).strokeWidth(1f)
280 | var polygon = aMap.addPolygon(polygonOptions);
281 | mPolygons.add(aMap.addPolygon(polygonOptions))
282 | }
283 | }
284 |
285 | /**
286 | * 关闭显示的电子围覆盖层
287 | */
288 | private fun closAllPolygonOptions() {
289 |
290 | for (polygon in mPolygons) {
291 | polygon.remove()
292 | }
293 | aMap.invalidate()
294 | }
295 | }
296 |
--------------------------------------------------------------------------------
/maplibrary/src/main/java/cn/lp/maplibrary/GdMapActivity.kt:
--------------------------------------------------------------------------------
1 | package cn.lp.maplibrary
2 |
3 | import android.graphics.Color
4 | import android.os.Bundle
5 | import android.support.v7.app.AppCompatActivity
6 | import android.util.Log
7 | import android.widget.Toast
8 | import cn.shequren.map.R
9 | import cn.shequren.map.R.layout
10 | import com.amap.api.location.AMapLocation
11 | import com.amap.api.location.AMapLocationClient
12 | import com.amap.api.location.AMapLocationClientOption
13 | import com.amap.api.location.AMapLocationListener
14 | import com.amap.api.maps2d.AMap
15 | import com.amap.api.maps2d.CameraUpdateFactory
16 | import com.amap.api.maps2d.LocationSource
17 | import com.amap.api.maps2d.model.*
18 | import kotlinx.android.synthetic.main.activity_gd_map.*
19 | import java.util.*
20 |
21 | /**
22 | * 高德地图显示、定位、轨迹绘制、Marker点绘制
23 | */
24 |
25 | class GdMapActivity : AppCompatActivity(), LocationSource, AMapLocationListener {
26 |
27 |
28 | /**
29 | * 地图控制器底下
30 | */
31 | lateinit var aMap: AMap
32 |
33 |
34 | var mListener: LocationSource.OnLocationChangedListener? = null
35 | var mlocationClient: AMapLocationClient? = null
36 |
37 | /**
38 | * 折线覆盖物对象
39 | */
40 | var polyline: Polyline? = null
41 | lateinit var mLocationOption: AMapLocationClientOption
42 |
43 | /**
44 | * 经纬度
45 | */
46 | var mLatitude: Double = 0.0
47 | var mLongitude: Double = 0.0
48 |
49 |
50 | /**
51 | * 成功回调
52 | */
53 | override fun onLocationChanged(aMapLocation: AMapLocation?) {
54 | //定位成功
55 | if (mListener != null && aMapLocation != null) {
56 | if (aMapLocation.getErrorCode() == 0) {
57 |
58 | mListener!!.onLocationChanged(aMapLocation)// 显示系统小蓝点
59 | val latLng = LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude())
60 | mLatitude = aMapLocation.getLatitude()
61 | mLongitude = aMapLocation.getLongitude()
62 |
63 | setLocationSuccess(latLng)
64 |
65 | } else {
66 | val errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo()
67 | Log.e("AmapErr", errText)
68 | }
69 | }
70 | }
71 |
72 | /**
73 | *停用回调
74 | */
75 | override fun deactivate() {
76 | mListener = null
77 | if (mlocationClient != null) {
78 | /**
79 | * 停止定位服务
80 | */
81 | mlocationClient!!.stopLocation()
82 | mlocationClient!!.onDestroy()
83 | }
84 | mlocationClient = null
85 | }
86 |
87 | /**
88 | * 激活定位
89 | */
90 | override fun activate(p0: LocationSource.OnLocationChangedListener?) {
91 | //设置定位参数和
92 | mListener = p0!!
93 | if (null == mlocationClient) {
94 | //定位服务类
95 | mlocationClient = AMapLocationClient(this)
96 | //定位的参数设置对象
97 | mLocationOption = AMapLocationClientOption()
98 | //设置定位监听
99 | mlocationClient!!.setLocationListener(this)
100 | //设置为高精度定位模式
101 | mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy)
102 |
103 | //定位间隔时间
104 | mLocationOption!!.setInterval(1000 * 2 * 60)
105 | //设置定位参数
106 | mlocationClient!!.setLocationOption(mLocationOption)
107 | // 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗,
108 | // 注意设置合适的定位时间的间隔(最小间隔支持为2000ms),并且在合适时间调用stopLocation()方法来取消定位请求
109 | // 在定位结束后,在合适的生命周期调用onDestroy()方法
110 | // 在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求,定位sdk内部会移除
111 |
112 | //启用定位
113 | mlocationClient!!.startLocation()
114 | }
115 | }
116 |
117 |
118 | override fun onCreate(savedInstanceState: Bundle?) {
119 | super.onCreate(savedInstanceState)
120 | setContentView(layout.activity_gd_map)
121 | // 此方法必须重写
122 | mapView.onCreate(savedInstanceState)
123 |
124 |
125 | intMap()
126 | intiView()
127 | }
128 |
129 | private fun intiView() {
130 |
131 | //修改地图模式
132 | type.setOnClickListener {
133 | if (aMap.mapType == AMap.MAP_TYPE_SATELLITE) {
134 | aMap.mapType = AMap.MAP_TYPE_NORMAL
135 | } else {
136 | aMap.mapType = AMap.MAP_TYPE_SATELLITE
137 | }
138 |
139 | }
140 |
141 | /**
142 | * 显示附近Marker覆盖物,像共享单车车站的位置
143 | */
144 | around.setOnClickListener {
145 |
146 | if (this.mLatitude != 0.0 && this.mLongitude != 0.0) {
147 | setAroundInfor(LatLng(mLatitude, mLongitude));
148 | } else {
149 | Toast.makeText(this, "位定位成功", Toast.LENGTH_LONG).show()
150 | }
151 |
152 | }
153 |
154 | /**
155 | * 显示轨迹,运动轨迹
156 | */
157 | trajectory.setOnClickListener {
158 |
159 | if (this.mLatitude != 0.0 && this.mLongitude != 0.0) {
160 | trajectory(LatLng(mLatitude, mLongitude));
161 | } else {
162 | Toast.makeText(this, "位定位成功", Toast.LENGTH_LONG).show()
163 | }
164 | }
165 | }
166 |
167 | private fun intMap() {
168 | this.aMap = mapView.map
169 |
170 | this.aMap.isTrafficEnabled = true// 显示实时交通状况
171 | //地图模式可选类型:MAP_TYPE_NORMAL,MAP_TYPE_SATELLITE,MAP_TYPE_NIGHT
172 | this.aMap.mapType = AMap.MAP_TYPE_NORMAL// 卫星地图模式
173 |
174 | ///aMap.setOnMapClickListener(this) //点击地图监听
175 | aMap.setLocationSource(this)// 设置定位监听
176 | aMap.moveCamera(CameraUpdateFactory.zoomTo(16f))//设置缩放级别
177 | aMap.uiSettings.isMyLocationButtonEnabled = true// 设置默认定位按钮是否显示
178 |
179 | aMap.isMyLocationEnabled = true// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
180 | // 设置定位的类型为定位模式 ,可以由定位、跟随或地图根据面向方向旋转几种
181 |
182 | //定位地图自动可以定位
183 | /* aMap.setOnCameraChangeListener(object : AMap.OnCameraChangeListener {
184 |
185 | override fun onCameraChange(cameraPosition: CameraPosition) {}
186 |
187 | override fun onCameraChangeFinish(cameraPosition: CameraPosition) {
188 | mLatitude = cameraPosition.target.latitude
189 | mLongitude = cameraPosition.target.longitude
190 | val latLng = LatLng(mLatitude, mLongitude)
191 | //setLocationSuccess(latLng)
192 | }
193 | })*/
194 |
195 | aMap.moveCamera(CameraUpdateFactory.zoomTo(24f))
196 |
197 | /**
198 | * 设置地图小蓝点
199 | */
200 | val myLocationStyle = MyLocationStyle()
201 | myLocationStyle.myLocationIcon(BitmapDescriptorFactory
202 | .fromResource(Color.BLACK))// 设置小蓝点的图标
203 | myLocationStyle.strokeColor(Color.BLACK)// 设置圆形的边框颜色
204 | myLocationStyle.radiusFillColor(Color.argb(100, 0, 0, 180))// 设置圆形的填充颜色
205 | // myLocationStyle.anchor(int,int)//设置小蓝点的锚点
206 | myLocationStyle.strokeWidth(2.0f)// 设置圆形的边框粗细
207 | aMap.setMyLocationStyle(myLocationStyle) // 将自定义的 myLocationStyle 对象添加到地图上
208 | }
209 |
210 | override fun onResume() {
211 | super.onResume()
212 | this.mapView.onResume()
213 | }
214 |
215 | override fun onPause() {
216 | super.onPause()
217 | this.mapView.onPause()
218 | }
219 |
220 | override fun onDestroy() {
221 | super.onDestroy()
222 | this.mapView.onDestroy()
223 | }
224 |
225 | override fun onSaveInstanceState(outState: Bundle) {
226 | super.onSaveInstanceState(outState)
227 | //在activity执行onSaveInstanceState时执行mMapView.onSaveInstanceState (outState),保存地图当前的状态
228 | mapView.onSaveInstanceState(outState)
229 | }
230 |
231 |
232 | private fun setLocationSuccess(latLng: LatLng) {
233 | aMap.animateCamera(CameraUpdateFactory.changeLatLng(latLng))
234 |
235 | }
236 |
237 | var isRningAroundInfor = false;
238 |
239 | /**
240 | * 显示周边
241 | */
242 | private fun setAroundInfor(latLng: LatLng) {
243 | /**
244 | * 使用固定变量判断,正式开发中根据业务需求决定是否重新绘制,需要注意的是重新绘制前需要清除绘制的信息,
245 | * 但是清除绘制会将从地图上删除所有的overlay(marker,circle,polyline 等对象)清除。
246 | */
247 | if (isRningAroundInfor) {
248 | Toast.makeText(this, "已经绘制过附近做坐标", Toast.LENGTH_LONG).show()
249 | //已经绘制过了
250 | return
251 | }
252 | isRningAroundInfor = true;
253 | /**
254 | * 真实开发中应该是一个Latlng的集合数据,这里就不用真实数据模拟20个点位数据
255 | */
256 | var lat: LatLng? = null
257 | var markerOptions = MarkerOptions()
258 | for (i in 1..20) {
259 | var a = Random().nextDouble() * 0.001;
260 |
261 | if (i / 6 == 0) {
262 | lat = LatLng(latLng.latitude + a, latLng.longitude + 5 * a)
263 | } else if (i / 6 == 1) {
264 | lat = LatLng(latLng.latitude + 3 * a, latLng.longitude - a)
265 | } else if (i / 6 == 2) {
266 | lat = LatLng(latLng.latitude - 2 * a, latLng.longitude + 5 * a)
267 | } else if (i / 6 == 3) {
268 | lat = LatLng(latLng.latitude - 5 * a, latLng.longitude - a)
269 | } else if (i / 6 == 3) {
270 | lat = LatLng(latLng.latitude - 4 * a, latLng.longitude + 3 * a)
271 | } else if (i / 6 == 4) {
272 | lat = LatLng(latLng.latitude + 5 * a, latLng.longitude - 2 * a)
273 | } else if (i / 6 == 5) {
274 | lat = LatLng(latLng.latitude - a, latLng.longitude - 3 * a)
275 | }
276 |
277 | markerOptions.position(lat)
278 | /**
279 | * 添加Marker覆盖物
280 | */
281 | markerOptions.icon(BitmapDescriptorFactory
282 | .fromResource(R.drawable.express_icon_location_centre_point))
283 | markerOptions.snippet("描述")
284 | markerOptions.title("标题")
285 | aMap.addMarker(markerOptions);
286 |
287 | }
288 |
289 | }
290 |
291 | var isRningtrajectory = false;
292 | private fun trajectory(latLng: LatLng) {
293 | /**
294 | * 真实开发中应该是一个Latlng的集合数据,这里就不用真实数据模拟20个点位数据
295 | */
296 |
297 |
298 | isRningtrajectory = true
299 |
300 | var lats = arrayListOf();
301 | var lat: LatLng? = null
302 |
303 | for (i in 1..20) {
304 | var a = Random().nextDouble() * 0.001;
305 | if (i / 6 == 0) {
306 | lat = LatLng(latLng.latitude + a, latLng.longitude + 5 * a)
307 | } else if (i / 6 == 1) {
308 | lat = LatLng(latLng.latitude + 3 * a, latLng.longitude - a)
309 | } else if (i / 6 == 2) {
310 | lat = LatLng(latLng.latitude - 2 * a, latLng.longitude + 5 * a)
311 | } else if (i / 6 == 3) {
312 | lat = LatLng(latLng.latitude - 5 * a, latLng.longitude - a)
313 | } else if (i / 6 == 3) {
314 | lat = LatLng(latLng.latitude - 4 * a, latLng.longitude + 3 * a)
315 | } else if (i / 6 == 4) {
316 | lat = LatLng(latLng.latitude + 5 * a, latLng.longitude - 2 * a)
317 | } else if (i / 6 == 5) {
318 | lat = LatLng(latLng.latitude - a, latLng.longitude - 3 * a)
319 | }
320 | if (lat != null) {
321 | lats.add(lat)
322 | }
323 | }
324 |
325 | if (polyline != null) {
326 | /**
327 | * 异常覆盖物
328 | */
329 | polyline!!.remove()
330 | }
331 |
332 | /**
333 | * 添加运功轨迹 并获取添加物对象
334 | */
335 | polyline = aMap.addPolyline(PolylineOptions()
336 | //手动数据测试
337 | //.add(new LatLng(26.57, 106.71),new LatLng(26.14,105.55),new LatLng(26.58, 104.82), new LatLng(30.67, 104.06))
338 | //集合数据
339 | .addAll(lats).width(10f).setDottedLine(false).geodesic(true)
340 | //颜色
341 | .color(Color.argb(255, 255, 20, 147)));
342 |
343 | }
344 | }
345 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
--------------------------------------------------------------------------------
/maplibrary/maplibrary.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
--------------------------------------------------------------------------------