├── .circleci
└── config.yml
├── .editorconfig
├── .github
└── workflows
│ ├── build.yml
│ ├── docs.yml
│ └── issues-stale.yml
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── GIF.gif
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
├── release
│ └── app-release.apk
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── king
│ │ └── map
│ │ └── maphelper
│ │ └── app
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── ic_launcher-playstore.png
│ ├── java
│ │ └── com
│ │ │ └── king
│ │ │ └── map
│ │ │ └── maphelper
│ │ │ └── app
│ │ │ └── MainActivity.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── king
│ └── map
│ └── maphelper
│ └── app
│ └── ExampleUnitTest.kt
├── build.gradle
├── build_docs.sh
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── maphelper
├── .gitignore
├── bintray.gradle
├── build.gradle
├── consumer-rules.pro
├── dokka.gradle
├── gradle.properties
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── king
│ │ └── map
│ │ └── maphelper
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── king
│ │ └── map
│ │ └── maphelper
│ │ ├── LatLng.kt
│ │ └── MapHelper.kt
│ └── test
│ └── java
│ └── com
│ └── king
│ └── map
│ └── maphelper
│ └── ExampleUnitTest.kt
├── mkdocs.yml
├── settings.gradle
└── versions.gradle
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2.1
2 |
3 | orbs:
4 | android: circleci/android@0.2.0
5 |
6 | jobs:
7 | build:
8 | executor: android/android
9 |
10 | steps:
11 | - checkout
12 | - run:
13 | command: ./gradlew build
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 4
6 | charset = utf-8
7 | trim_trailing_whitespace = true
8 | insert_final_newline = true
9 |
10 | [*.{kt, kts}]
11 | ij_kotlin_imports_layout = *
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: build
2 |
3 | on:
4 | push:
5 | branches: [ master ]
6 | pull_request:
7 | branches: [ master ]
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-latest
12 |
13 | steps:
14 | - uses: actions/checkout@v2
15 | - name: Set up JDK 11
16 | uses: actions/setup-java@v1
17 | with:
18 | java-version: 11
19 | - name: Build with Gradle
20 | run: ./gradlew build
--------------------------------------------------------------------------------
/.github/workflows/docs.yml:
--------------------------------------------------------------------------------
1 | name: docs
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 |
8 | env:
9 | JAVA_VERSION: 11
10 | PYTHON_VERSION: 3.x
11 | GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.daemon=false -Dkotlin.incremental=false"
12 |
13 | permissions:
14 | contents: write
15 | id-token: write
16 | pages: write
17 |
18 | jobs:
19 | docs:
20 | environment:
21 | name: github-pages
22 | url: ${{ steps.deployment.outputs.page_url }}
23 | runs-on: ubuntu-latest
24 | if: github.ref == 'refs/heads/master'
25 |
26 | steps:
27 | - name: Checkout
28 | uses: actions/checkout@v4
29 | with:
30 | fetch-depth: 0
31 |
32 | - name: Configure JDK
33 | uses: actions/setup-java@v4
34 | with:
35 | distribution: 'zulu'
36 | java-version: ${{ env.JAVA_VERSION }}
37 |
38 | - name: Install Python
39 | uses: actions/setup-python@v5
40 | with:
41 | python-version: ${{ env.PYTHON_VERSION }}
42 |
43 | - name: Install MkDocs Material
44 | run: pip install mkdocs-material
45 |
46 | - name: Generate Docs
47 | run: ./build_docs.sh
48 |
49 | - name: Upload to GitHub Pages
50 | uses: actions/upload-pages-artifact@v3
51 | with:
52 | path: site
53 |
54 | - name: Deploy to GitHub Pages
55 | id: deployment
56 | uses: actions/deploy-pages@v4
57 |
--------------------------------------------------------------------------------
/.github/workflows/issues-stale.yml:
--------------------------------------------------------------------------------
1 | name: 'Close stale issues and PRs'
2 | on:
3 | schedule:
4 | - cron: '0 16 * * *'
5 |
6 | jobs:
7 | stale:
8 | runs-on: ubuntu-latest
9 | permissions:
10 | issues: write
11 | pull-requests: write
12 | steps:
13 | - uses: actions/stale@v5
14 | with:
15 | stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
16 | days-before-stale: 30
17 | days-before-close: 5
18 | exempt-all-pr-milestones: true
19 | exempt-issue-labels: 'help wanted'
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 | .cxx
10 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 | dist: trusty
3 | jdk: oraclejdk8
4 | sudo: false
5 |
6 | env:
7 | global:
8 | - ANDROID_API_LEVEL=29
9 | - ANDROID_BUILD_TOOLS_VERSION=29.0.3
10 | - TRAVIS_SECURE_ENV_VARS=true
11 |
12 | before_install:
13 | - chmod +x gradlew
14 | - mkdir "$ANDROID_HOME/licenses" || true
15 | # Hack to accept Android licenses
16 | - yes | sdkmanager "platforms;android-$ANDROID_API_LEVEL"
17 |
18 |
19 | android:
20 | components:
21 | # The BuildTools version used by your project
22 | - tools
23 | - platform-tools
24 | - build-tools-$ANDROID_BUILD_TOOLS_VERSION
25 | # The SDK version used to compile your project
26 | - android-$ANDROID_API_LEVEL
27 | - extra-android-m2repository
28 | - extra-google-android-support
29 |
30 | script:
31 | - ./gradlew clean
32 | - ./gradlew assembleRelease
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 版本日志
2 |
3 | #### v1.2.0:2023-7-26
4 | * 适配Android 11 (R) 软件包的可见性
5 |
6 | #### v1.1.0:2023-3-26
7 | * 迁移发布至 Maven Central
8 |
9 | #### v1.0.0:2020-5-3
10 | * MapHelper初始版本
11 |
--------------------------------------------------------------------------------
/GIF.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/GIF.gif
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Jenly
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MapHelper
2 |
3 | 
4 |
5 | [](https://repo1.maven.org/maven2/com/github/jenly1314/MapHelper)
6 | [](https://jitpack.io/#jenly1314/MapHelper)
7 | [](https://github.com/jenly1314/MapHelper/actions/workflows/build.yml)
8 | [](https://raw.githubusercontent.com/jenly1314/MapHelper/master/app/release/app-release.apk)
9 | [](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)
10 | [](https://opensource.org/licenses/mit)
11 |
12 | MapHelper for Android 是一个整合了高德地图、百度地图、腾讯地图、谷歌地图等相关路线规划和导航的地图帮助类库。
13 |
14 | ## 功能介绍
15 | - ✅ 简单易用,一句代码实现
16 | - ✅ 地图路线规划/导航
17 | - ✅ **GCJ-02** / **WGS-84** / **BD09LL** 等相关坐标系互转
18 |
19 | ## 效果展示
20 | 
21 |
22 | > 你也可以直接下载 [演示App](https://raw.githubusercontent.com/jenly1314/MapHelper/master/app/release/app-release.apk) 体验效果
23 |
24 | ## 引入
25 |
26 | ### Gradle:
27 |
28 | 1. 在Project的 **build.gradle** 或 **setting.gradle** 中添加远程仓库
29 |
30 | ```gradle
31 | repositories {
32 | //...
33 | mavenCentral()
34 | }
35 | ```
36 |
37 | 2. 在Module的 **build.gradle** 中添加依赖项
38 | ```gradle
39 | implementation 'com.github.jenly1314:maphelper:1.2.0'
40 | ```
41 |
42 | ## 使用
43 |
44 | ### 代码示例
45 |
46 | ```kotlin
47 | // 调用相关地图线路/导航示例(params表示一些具体参数)
48 |
49 | // 跳转到地图(高德、百度、腾讯、谷歌地图等)
50 | MapHelper.gotoMap(params)
51 | // 跳转到高德地图
52 | MapHelper.gotoAMap(params)
53 | // 跳转到百度地图
54 | MapHelper.gotoBaiduMap(params)
55 | // 跳转腾讯地图
56 | MapHelper.gotoTencentMap(params)
57 | // 跳转到谷歌地图
58 | MapHelper.gotoGoogleMap(params)
59 | // 坐标系转换:WGS-84转GCJ-02(火星坐标系)
60 | MapHelper.wgs84ToGCJ02(latitude,longitude)
61 | // 坐标系转换:GCJ-02(火星坐标系)转WGS-84
62 | MapHelper.gcj02ToWGS84(latitude,longitude)
63 | //...
64 | ```
65 | 更多使用详情,请查看[app](app)中的源码使用示例或直接查看 [API帮助文档](https://jenly1314.github.io/MapHelper/api/)
66 |
67 | ## 相关推荐
68 |
69 | - [Location](https://github.com/jenly1314/Location) 一个通过 Android 自带的 LocationManager 来实现的定位功能。
70 | - [RetrofitHelper](http://github.com/jenly1314/RetrofitHelper) 一个支持动态改变BaseUrl,动态配置超时时长的Retrofit帮助类。
71 | - [BaseUrlManager](http://github.com/jenly1314/BaseUrlManager) 一个BaseUrl管理器,主要用于打测试包时,一个App可动态切换到不同的开发环境或测试环境。
72 | - [AppUpdater](http://github.com/jenly1314/AppUpdater) 一个专注于App更新,一键傻瓜式集成App版本升级的轻量开源库。
73 | - [ImageViewer](http://github.com/AndroidKTX/ImageViewer) 一个图片查看器,一般用来查看图片详情或查看大图时使用。
74 | - [LogX](http://github.com/jenly1314/LogX) 一个轻量而强大的日志框架;好用不解释。
75 | - [KVCache](http://github.com/jenly1314/KVCache) 一个便于统一管理的键值缓存库;支持无缝切换缓存实现。
76 | - [AndroidKTX](http://github.com/AndroidKTX/AndroidKTX) 一个简化 Android 开发的 Kotlin 工具类集合。
77 | - [AndroidUtil](http://github.com/AndroidUtil/AndroidUtil) 一个整理了Android常用工具类集合,平时在开发的过程中可能会经常用到。
78 |
79 |
80 |
81 | ## 版本日志
82 |
83 | #### v1.2.0:2023-7-26
84 | * 适配Android 11 (R) 软件包的可见性
85 |
86 | #### [查看更多版本日志](CHANGELOG.md)
87 |
88 | ---
89 |
90 | 
91 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'org.jetbrains.kotlin.android'
4 | }
5 |
6 | android {
7 | compileSdk build_versions.compileSdk
8 |
9 | defaultConfig {
10 | applicationId "com.king.map.maphelper.app"
11 | minSdk build_versions.minSdk
12 | targetSdk build_versions.targetSdk
13 | versionCode app_version.versionCode
14 | versionName app_version.versionName
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | vectorDrawables {
18 | useSupportLibrary true
19 | }
20 | }
21 |
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 | compileOptions {
29 | sourceCompatibility JavaVersion.VERSION_1_8
30 | targetCompatibility JavaVersion.VERSION_1_8
31 | }
32 | kotlinOptions {
33 | jvmTarget = JavaVersion.VERSION_1_8.toString()
34 | }
35 | lintOptions {
36 | abortOnError false
37 | }
38 |
39 | }
40 |
41 | dependencies {
42 | implementation "androidx.core:core-ktx:$versions.coreKtx"
43 | implementation "androidx.appcompat:appcompat:$versions.appcompat"
44 | implementation "androidx.constraintlayout:constraintlayout:$versions.constraintlayout"
45 |
46 | testImplementation "junit:junit:$versions.junit"
47 | androidTestImplementation "androidx.test.ext:junit:$versions.androidExtJunit"
48 | androidTestImplementation "androidx.test.espresso:espresso-core:$versions.espressoCore"
49 |
50 | implementation project(":maphelper")
51 | }
52 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/release/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/release/app-release.apk
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/king/map/maphelper/app/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.king.map.maphelper.app
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.king.map.maphelper.app", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
9 |
16 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/app/src/main/java/com/king/map/maphelper/app/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.king.map.maphelper.app
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import android.view.View
6 | import com.king.map.maphelper.MapHelper
7 |
8 | /**
9 | * @author Jenly
10 | */
11 | class MainActivity : AppCompatActivity() {
12 |
13 | override fun onCreate(savedInstanceState: Bundle?) {
14 | super.onCreate(savedInstanceState)
15 | setContentView(R.layout.activity_main)
16 | }
17 |
18 | /**
19 | * 跳转到地图路线规划,只要本地有高德,百度,腾讯,谷歌,地图任意一个App就会自动跳转
20 | */
21 | fun gotoMap() {
22 | MapHelper.gotoMap(this, 22.609875, 114.0295, MapHelper.MapType.UNSPECIFIED_MAP_TYPE)
23 | }
24 |
25 | /**
26 | * 跳转到高德地图
27 | * @param isRoute 为true表示跳转到地图路线规划,为false表示跳转到导航
28 | */
29 | fun gotoAMap(isRoute: Boolean) {
30 | MapHelper.gotoAMap(this, 22.609875, 114.0295, false, isRoute = isRoute, isMarket = true)
31 | }
32 |
33 | /**
34 | * 跳转到百度地图
35 | * @param isRoute 为true表示跳转到地图路线规划,为false表示跳转到导航
36 | */
37 | fun gotoBaiduMap(isRoute: Boolean) {
38 | MapHelper.gotoBaiduMap(
39 | this,
40 | 22.609875,
41 | 114.0295,
42 | MapHelper.CoordinateType.GCJ02,
43 | isRoute = isRoute,
44 | isMarket = true
45 | )
46 | }
47 |
48 | /**
49 | * 跳转到腾讯地图
50 | */
51 | fun gotoTencentMap() {
52 | MapHelper.gotoTencentMap(this, 22.609875, 114.0295, isMarket = true)
53 | }
54 |
55 | /**
56 | * 跳转到谷歌地图
57 | */
58 | fun gotoGoogleMap() {
59 | MapHelper.gotoGoogleMap(this, 22.609875, 114.0295, isMarket = true)
60 | }
61 |
62 | fun onClick(v: View) {
63 | when (v.id) {
64 | R.id.btnMap -> gotoMap()
65 | R.id.btnAMapNavi -> gotoAMap(false)
66 | R.id.btnAMapRoute -> gotoAMap(true)
67 | R.id.btnBaiduMapNavi -> gotoBaiduMap(false)
68 | R.id.btnBaiduMapRoute -> gotoBaiduMap(true)
69 | R.id.btnTencentMapRoute -> gotoTencentMap()
70 | R.id.btnGoogleMapNavi -> gotoGoogleMap()
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
20 |
30 |
40 |
50 |
60 |
70 |
80 |
81 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #A1E1E1
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MapHelper
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/test/java/com/king/map/maphelper/app/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.king.map.maphelper.app
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | apply from: 'versions.gradle'
3 | }// Top-level build file where you can add configuration options common to all sub-projects/modules.
4 | plugins {
5 | id 'com.android.application' version '7.2.1' apply false
6 | id 'com.android.library' version '7.2.1' apply false
7 | id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
8 | id 'org.jetbrains.dokka' version '1.9.20' apply false
9 | id 'com.vanniktech.maven.publish' version '0.22.0' apply false
10 | }
11 |
--------------------------------------------------------------------------------
/build_docs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -ex
4 |
5 | # Generate the API docs
6 | ./gradlew dokkaHtml
7 |
8 | mkdir -p docs/api
9 | mv maphelper/build/dokka/html/* docs/api
10 |
11 | # Copy in special files that GitHub wants in the project root.
12 | GITHUB_URL=https://github.com/jenly1314/MapHelper/
13 | echo $GITHUB_URL
14 | sed "//q" README.md > docs/index.md
15 | sed -i "s|app/src/main/ic_launcher-playstore.png|ic_logo.png|g" docs/index.md
16 | sed -i "s|](app|](${GITHUB_URL}blob/master/app|g" docs/index.md
17 | cat CHANGELOG.md | grep -v '## 版本日志' > docs/changelog.md
18 |
19 | cp GIF.gif docs/GIF.gif
20 | cp app/src/main/ic_launcher-playstore.png docs/ic_logo.png
21 |
22 | # Build the site locally
23 | mkdocs build
24 |
--------------------------------------------------------------------------------
/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 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 |
23 | VERSION_NAME=1.2.0
24 | VERSION_CODE=3
25 | GROUP=com.github.jenly1314
26 |
27 | POM_DESCRIPTION=MapHelper for Android
28 | POM_URL=https://github.com/jenly1314/MapHelper
29 |
30 | POM_SCM_URL=https://github.com/jenly1314/MapHelper
31 | POM_SCM_CONNECTION=scm:git@github.com:jenly1314/MapHelper.git
32 | POM_SCM_DEV_CONNECTION=scm:git@github.com:jenly1314/MapHelper.git
33 |
34 | POM_LICENCE_NAME=The MIT License
35 | POM_LICENCE_URL=https://opensource.org/licenses/mit-license.php
36 | #POM_LICENCE_NAME=The Apache Software License, Version 2.0
37 | #POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
38 | POM_LICENSE_DIST=repo
39 |
40 | POM_DEVELOPER_ID=jenly
41 | POM_DEVELOPER_NAME=Jenly Yu
42 | POM_DEVELOPER_URL=https://github.com/jenly1314/
43 |
44 | #RELEASE_REPOSITORY_URL=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
45 | #SNAPSHOT_REPOSITORY_URL=https://s01.oss.sonatype.org/content/repositories/snapshots/
46 |
47 | SONATYPE_HOST=S01
48 |
49 | RELEASE_SIGNING_ENABLED=false
50 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenly1314/MapHelper/4b02a294adababb4521a3d26c5147bb88b4c2c5c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat May 02 19:02:09 CST 2020
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-7.3.3-bin.zip
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/maphelper/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/maphelper/bintray.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.novoda.bintray-release'
2 |
3 | //添加
4 | publish {
5 | userOrg = 'jenly'//bintray.com用户名
6 | groupId = 'com.king.map'//jcenter上的路径
7 | artifactId = 'maphelper'//项目名称
8 | publishVersion = app_version.versionName//版本号
9 | desc = 'MapHelper for Android'//描述
10 | website = 'https://github.com/jenly1314/MapHelper'//网站
11 | licences = ['MIT']//开源协议
12 | }
--------------------------------------------------------------------------------
/maphelper/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'org.jetbrains.kotlin.android'
4 | id 'org.jetbrains.dokka'
5 | id 'com.vanniktech.maven.publish'
6 | id 'kotlin-parcelize'
7 | }
8 |
9 | android {
10 | compileSdk build_versions.compileSdk
11 |
12 | defaultConfig {
13 | minSdk build_versions.minSdk
14 | targetSdk build_versions.targetSdk
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | consumerProguardFiles "consumer-rules.pro"
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 | compileOptions {
27 | sourceCompatibility JavaVersion.VERSION_1_8
28 | targetCompatibility JavaVersion.VERSION_1_8
29 | }
30 | kotlinOptions {
31 | jvmTarget = JavaVersion.VERSION_1_8.toString()
32 | }
33 | lintOptions {
34 | abortOnError false
35 | }
36 | }
37 |
38 | dependencies {
39 |
40 | implementation "androidx.core:core-ktx:$versions.coreKtx"
41 |
42 | testImplementation "junit:junit:$versions.junit"
43 | androidTestImplementation "androidx.test.ext:junit:$versions.androidExtJunit"
44 | androidTestImplementation "androidx.test.espresso:espresso-core:$versions.espressoCore"
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/maphelper/consumer-rules.pro:
--------------------------------------------------------------------------------
1 | -dontwarn com.king.map.maphelper.**
2 | -keep class com.king.map.maphelper.**{ *;}
3 |
4 | -keep class * implements android.os.Parcelable {
5 | public static final android.os.Parcelable$Creator *;
6 | }
--------------------------------------------------------------------------------
/maphelper/dokka.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'org.jetbrains.dokka'
2 |
3 | android {
4 | dokka {
5 | outputFormat = 'javadoc'
6 | outputDirectory = "$buildDir/kdoc"
7 | configuration {
8 | // Do not output deprecated members
9 | skipDeprecated = true
10 | // Emit warnings about not documented members.
11 | reportUndocumented = true
12 | // Do not create index pages for empty packages
13 | skipEmptyPackages = true
14 |
15 | noJdkLink = true
16 | noStdlibLink = true
17 | noAndroidSdkLink = true
18 | }
19 |
20 | }
21 | }
--------------------------------------------------------------------------------
/maphelper/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=MapHelper
2 | POM_ARTIFACT_ID=maphelper
3 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/maphelper/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 |
--------------------------------------------------------------------------------
/maphelper/src/androidTest/java/com/king/map/maphelper/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.king.map.maphelper
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.king.map.maphelper.test", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/maphelper/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/maphelper/src/main/java/com/king/map/maphelper/LatLng.kt:
--------------------------------------------------------------------------------
1 | package com.king.map.maphelper
2 |
3 | import android.os.Parcelable
4 | import kotlinx.parcelize.Parcelize
5 |
6 | /**
7 | * 坐标经纬度
8 | *
9 | * @param latitude 纬度
10 | * @param longitude 经度
11 | *
12 | * @author Jenly
13 | */
14 | @Parcelize
15 | data class LatLng(val latitude: Double, val longitude: Double) : Parcelable
--------------------------------------------------------------------------------
/maphelper/src/main/java/com/king/map/maphelper/MapHelper.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("unused", "QueryPermissionsNeeded")
2 |
3 | package com.king.map.maphelper
4 |
5 | import android.content.Context
6 | import android.content.Intent
7 | import android.net.Uri
8 | import android.text.TextUtils
9 | import android.util.Log
10 | import java.lang.Exception
11 | import kotlin.math.*
12 |
13 | /**
14 | * 一个整合了高德地图、百度地图、腾讯地图、谷歌地图等相关路线规划和导航的地图帮助类库。
15 | *
16 | * @author Jenly
17 | */
18 | object MapHelper {
19 |
20 | private const val TAG = "MapHelper"
21 |
22 | //---------------------------------------------
23 | /**
24 | * 高德地图App包名
25 | */
26 | private const val AMAP_PACKAGE_NAME = "com.autonavi.minimap"
27 |
28 | /**
29 | * 百度地图App包名
30 | */
31 | private const val BAIDU_MAP_PACKAGE_NAME = "com.baidu.BaiduMap"
32 |
33 | /**
34 | * 腾讯地图App包名
35 | */
36 | private const val TENCENT_MAP_PACKAGE_NAME = "com.tencent.map"
37 |
38 | /**
39 | * 谷歌地图App包名
40 | */
41 | private const val GOOGLE_MAP_PACKAGE_NAME = "com.google.android.apps.maps"
42 |
43 |
44 | //---------------------------------------------
45 |
46 | /**
47 | * 坐标系类型
48 | */
49 | object CoordinateType {
50 | /**
51 | * 经国测局加密后的坐标系(火星坐标系)
52 | */
53 | const val GCJ02 = "gcj02"
54 |
55 | /**
56 | * GPS原始坐标系
57 | */
58 | const val WGS84 = "wgs84"
59 |
60 | /**
61 | * 百度经纬度坐标系
62 | */
63 | const val BD09LL = "bd09ll"
64 |
65 | /**
66 | * 百度墨卡托坐标系
67 | */
68 | const val BD09MC = "bd09mc"
69 | }
70 |
71 | //---------------------------------------------
72 |
73 | /**
74 | * 出行方式
75 | */
76 | object TripMode {
77 | /**
78 | * 驾车
79 | */
80 | const val DRIVING_MODE = 0
81 |
82 | /**
83 | * 公交
84 | */
85 | const val TRANSIT_MODE = 1
86 |
87 | /**
88 | * 步行
89 | */
90 | const val WALKING_MODE = 2
91 |
92 | /**
93 | * 骑行
94 | */
95 | const val RIDING_MODE = 3
96 |
97 |
98 | //---------------------------------------------
99 | /**
100 | * 百度地图-驾车
101 | */
102 | internal const val BAIDU_DRIVING_MODE = "driving"
103 |
104 | /**
105 | * 百度地图-公交
106 | */
107 | internal const val BAIDU_TRANSIT_MODE = "transit"
108 |
109 | /**
110 | * 百度地图-步行
111 | */
112 | internal const val BAIDU_WALKING_MODE = "walking"
113 |
114 | /**
115 | * 百度地图-骑行
116 | */
117 | internal const val BAIDU_RIDING_MODE = "riding"
118 |
119 | //---------------------------------------------
120 | /**
121 | * 腾讯地图-驾车
122 | */
123 | internal const val TENCENT_DRIVING_MODE = "drive"
124 |
125 | /**
126 | * 腾讯地图-公交
127 | */
128 | internal const val TENCENT_TRANSIT_MODE = "bus"
129 |
130 | /**
131 | * 腾讯地图-步行
132 | */
133 | internal const val TENCENT_WALKING_MODE = "walk"
134 |
135 | /**
136 | * 腾讯地图-骑行
137 | */
138 | internal const val TENCENT_RIDING_MODE = "bike"
139 |
140 | //---------------------------------------------
141 | /**
142 | * 谷歌地图-驾车 | driving
143 | */
144 | internal const val GOOGLE_DRIVING_MODE = "d"
145 |
146 | /**
147 | * 谷歌地图-两轮车 | two-wheeler
148 | */
149 | internal const val GOOGLE_TRANSIT_MODE = "l"
150 |
151 | /**
152 | * 谷歌地图-步行 | walking
153 | */
154 | internal const val GOOGLE_WALKING_MODE = "w"
155 |
156 | /**
157 | * 谷歌地图-骑行 | bicycling
158 | */
159 | internal const val GOOGLE_RIDING_MODE = "b"
160 |
161 | //---------------------------------------------
162 | }
163 |
164 | /**
165 | * 腾讯地图默认的Referer
166 | */
167 | @JvmStatic
168 | private var DEFAULT_REFERER = "AppKey"
169 |
170 | //---------------------------------------------
171 | /**
172 | * 地图类型
173 | */
174 | object MapType {
175 | /**
176 | * 不指定地图类型
177 | */
178 | const val UNSPECIFIED_MAP_TYPE = 0
179 |
180 | /**
181 | * 高德地图类型
182 | */
183 | const val AMAP_TYPE = 1
184 |
185 | /**
186 | * 百度地图类型
187 | */
188 | const val BAIDU_MAP_TYPE = 2
189 |
190 | /**
191 | * 腾讯地图类型
192 | */
193 | const val TENCENT_MAP_TYPE = 3
194 |
195 | /**
196 | * 谷歌地图类型
197 | */
198 | const val GOOGLE_MAP_TYPE = 4
199 |
200 | }
201 | //---------------------------------------------
202 |
203 | /**
204 | * 根据App包名判断是否安装App
205 | * @param context
206 | * @param packageName 需要检测的App包名,目前定义了一些主流地图App包名
207 | * - [AMAP_PACKAGE_NAME] 高德地图App包名
208 | * - [BAIDU_MAP_PACKAGE_NAME] 百度地图App包名
209 | * - [TENCENT_MAP_PACKAGE_NAME] 腾讯地图App包名
210 | * - [GOOGLE_MAP_PACKAGE_NAME] 谷歌地图App包名
211 | */
212 | @JvmStatic
213 | private fun isInstalled(context: Context, packageName: String): Boolean {
214 | val manager = context.packageManager
215 | // 获取所有已安装程序的包信息
216 | val installedPackages = manager.getInstalledPackages(0)
217 | for (info in installedPackages) {
218 | if (info.packageName == packageName) return true
219 | }
220 | return false
221 | }
222 |
223 | //---------------------------------------------
224 |
225 | /**
226 | * 跳转到地图App路线导航
227 | *
228 | * @param context
229 | * @param toLatitude 终点纬度,请使用GCJ-02坐标系
230 | * @param toLongitude 终点经度,请使用GCJ-02坐标系
231 | * @param mapType 地图类型,默认为:[MapType.UNSPECIFIED_MAP_TYPE]。当 mapType为 [MapType.UNSPECIFIED_MAP_TYPE]时(跳转到已安装地图App,优先级顺序为:高德、百度、腾讯、谷歌地图)
232 | * - [MapType.UNSPECIFIED_MAP_TYPE] 不指定地图类型
233 | * - [MapType.AMAP_TYPE] 高德地图类型
234 | * - [MapType.BAIDU_MAP_TYPE] 百度地图类型
235 | * - [MapType.TENCENT_MAP_TYPE] 腾讯地图类型
236 | * - [MapType.GOOGLE_MAP_TYPE] 谷歌地图类型
237 | * @param isMarket 当检测到未安装目标App时,是否跳转到应用市场,默认为false,表示不跳转
238 | * @return 返回true表示满足条件并执行了跳转操作(跳转到相关地图App或跳转到应用市场对应App详情)
239 | */
240 | @JvmStatic
241 | @JvmOverloads
242 | fun gotoMap(
243 | context: Context,
244 | toLatitude: Double,
245 | toLongitude: Double,
246 | mapType: Int = MapType.UNSPECIFIED_MAP_TYPE,
247 | isMarket: Boolean = false,
248 | isContainGoogle: Boolean = true
249 | ): Boolean {
250 | return when (mapType) {
251 | MapType.UNSPECIFIED_MAP_TYPE -> gotoMap(
252 | context,
253 | toLatitude,
254 | toLongitude,
255 | isMarket,
256 | isContainGoogle
257 | )
258 | MapType.AMAP_TYPE -> gotoAMap(
259 | context,
260 | toLatitude,
261 | toLongitude,
262 | isRoute = true,
263 | isMarket = isMarket
264 | )
265 | MapType.BAIDU_MAP_TYPE -> gotoBaiduMap(
266 | context,
267 | toLatitude,
268 | toLongitude,
269 | isRoute = true,
270 | isMarket = isMarket
271 | )
272 | MapType.TENCENT_MAP_TYPE -> gotoTencentMap(
273 | context,
274 | toLatitude,
275 | toLongitude,
276 | isMarket = isMarket
277 | )
278 | MapType.GOOGLE_MAP_TYPE -> gotoGoogleMap(
279 | context,
280 | toLatitude,
281 | toLongitude,
282 | isMarket = isMarket
283 | )
284 | else -> false
285 | }
286 | }
287 |
288 | /**
289 | * 跳转到地图App路线导航,优先级顺序为:高德、百度、腾讯、谷歌地图
290 | *
291 | * @param context
292 | * @param toLatitude 终点纬度,请使用GCJ-02坐标系
293 | * @param toLongitude 终点经度,请使用GCJ-02坐标系
294 | * @param isMarket 当检测到未安装目标App时,是否跳转到应用市场,默认为false,表示不跳转
295 | * @param isContainGoogle 是否包含谷歌地图,因为国内很大可能都不需要使用google地图
296 | * @return 返回true表示满足条件并执行了跳转操作(跳转到相关地图App或跳转到应用市场对应App详情)
297 | */
298 | @JvmStatic
299 | private fun gotoMap(
300 | context: Context,
301 | toLatitude: Double,
302 | toLongitude: Double,
303 | isMarket: Boolean = false,
304 | isContainGoogle: Boolean = true
305 | ): Boolean {
306 | when {
307 | isInstalled(context, AMAP_PACKAGE_NAME) -> {
308 | return gotoAMap(
309 | context,
310 | toLatitude,
311 | toLongitude,
312 | isRoute = true,
313 | isMarket = isMarket
314 | )
315 | }
316 | isInstalled(context, BAIDU_MAP_PACKAGE_NAME) -> {
317 | return gotoBaiduMap(
318 | context,
319 | toLatitude,
320 | toLongitude,
321 | isRoute = true,
322 | isMarket = isMarket
323 | )
324 | }
325 | isInstalled(context, TENCENT_MAP_PACKAGE_NAME) -> {
326 | gotoTencentMap(context, toLatitude, toLongitude, isMarket = isMarket)
327 | return true
328 | }
329 | isContainGoogle && isInstalled(context, GOOGLE_MAP_PACKAGE_NAME) -> {
330 | return gotoGoogleMap(context, toLatitude, toLongitude, isMarket = isMarket)
331 | }
332 | isMarket -> {
333 | return gotoMarket(context, AMAP_PACKAGE_NAME)
334 | }
335 | else -> return false
336 | }
337 | }
338 |
339 | /**
340 | * 跳转到高德地图
341 | *
342 | * 参见:[高德地图 - 导航](https://lbs.amap.com/api/amap-mobile/guide/android/navigation)
343 | *
344 | * @param context
345 | * @param toLatitude 终点纬度
346 | * @param toLongitude 终点经度
347 | * @param isWGS84 为true表示使用GPS原始坐标系:wgs84,为false表示使用火星坐标系:gcj02
348 | * @param source 第三方调用应用名称。默认为:amap
349 | * @param isRoute 为true表示跳转到地图路线规划,为false表示跳转到导航
350 | * @param isMarket 当检测到未安装目标App时,是否跳转到应用市场,默认为false,表示不跳转
351 | * @param marketPackage 当跳转到应用市场时,指定具体的应用市场包名。如:华为,小米,应用宝等各大应用市场,默认为空,表示不指定
352 | */
353 | @JvmStatic
354 | @JvmOverloads
355 | fun gotoAMap(
356 | context: Context,
357 | toLatitude: Double,
358 | toLongitude: Double,
359 | isWGS84: Boolean = false,
360 | source: String = "amap",
361 | isRoute: Boolean,
362 | isMarket: Boolean = false,
363 | marketPackage: String? = null
364 | ): Boolean {
365 | return if (isRoute) {
366 | gotoAMapRoute(
367 | context,
368 | toLatitude = toLatitude,
369 | toLongitude = toLongitude,
370 | isWGS84 = isWGS84,
371 | source = source,
372 | isMarket = isMarket,
373 | marketPackage = marketPackage
374 | )
375 | } else {
376 | gotoAMapNavigation(
377 | context,
378 | toLatitude,
379 | toLongitude,
380 | isWGS84,
381 | source,
382 | isMarket,
383 | marketPackage
384 | )
385 | }
386 | }
387 |
388 | /**
389 | * 跳转到高德地图导航
390 | *
391 | * 参见:[高德地图 - 导航](https://lbs.amap.com/api/amap-mobile/guide/android/navigation)
392 | *
393 | * @param context
394 | * @param toLatitude 终点纬度
395 | * @param toLongitude 终点经度
396 | * @param isWGS84 为true表示使用GPS原始坐标系:wgs84,为false表示使用火星坐标系:gcj02
397 | * @param source 第三方调用应用名称。默认为:amap
398 | * @param isMarket 当检测到未安装目标App时,是否跳转到应用市场,默认为false,表示不跳转
399 | * @param marketPackage 当跳转到应用市场时,指定具体的应用市场包名。如:华为,小米,应用宝等各大应用市场,默认为空,表示不指定
400 | */
401 | @JvmStatic
402 | @JvmOverloads
403 | fun gotoAMapNavigation(
404 | context: Context,
405 | toLatitude: Double,
406 | toLongitude: Double,
407 | isWGS84: Boolean = false,
408 | source: String = "amap",
409 | isMarket: Boolean = false,
410 | marketPackage: String? = null
411 | ): Boolean {
412 | val dev = if (isWGS84) 1 else 0
413 | val uri =
414 | "androidamap://navi?sourceApplication=${source}&lat=${toLatitude}&lon=${toLongitude}&dev=${dev}&style=2"
415 | return gotoUri(context, AMAP_PACKAGE_NAME, Uri.parse(uri), isMarket, marketPackage)
416 | }
417 |
418 | /**
419 | * 跳转到高德地图路线规划
420 | *
421 | * 参见:[高德地图 - 路径规划](https://lbs.amap.com/api/amap-mobile/guide/android/route)
422 | *
423 | * @param context
424 | * @param toLatitude 终点纬度
425 | * @param toLongitude 终点经度
426 | * @param isWGS84 为true表示使用GPS原始坐标系:wgs84,为false表示使用火星坐标系:gcj02
427 | * @param mode 出行模式 默认为:[TripMode.DRIVING_MODE]
428 | * - [TripMode.DRIVING_MODE] 驾车模式
429 | * - [TripMode.TRANSIT_MODE] 公交模式
430 | * - [TripMode.WALKING_MODE] 步行模式
431 | * - [TripMode.RIDING_MODE] 骑行模式
432 | * @param source 第三方调用应用名称。默认为:amap
433 | * @param isMarket 当检测到未安装目标App时,是否跳转到应用市场,默认为false,表示不跳转
434 | * @param marketPackage 当跳转到应用市场时,指定具体的应用市场包名。如:华为,小米,应用宝等各大应用市场,默认为空,表示不指定
435 | */
436 | @JvmStatic
437 | @JvmOverloads
438 | fun gotoAMapRoute(
439 | context: Context,
440 | toLatitude: Double,
441 | toLongitude: Double,
442 | isWGS84: Boolean = false,
443 | mode: Int = TripMode.DRIVING_MODE,
444 | source: String = "amap",
445 | isMarket: Boolean = false,
446 | marketPackage: String? = null
447 | ): Boolean {
448 | return gotoAMapRoute(
449 | context,
450 | null,
451 | null,
452 | toLatitude,
453 | toLongitude,
454 | isWGS84,
455 | mode,
456 | source,
457 | isMarket,
458 | marketPackage
459 | )
460 | }
461 |
462 | /**
463 | * 跳转到高德地图路线规划
464 | *
465 | * 参见:[高德地图 - 路径规划](https://lbs.amap.com/api/amap-mobile/guide/android/route)
466 | *
467 | * @param context
468 | * @param fromLatitude 起点纬度,为空表示当前位置
469 | * @param fromLongitude 起点经度,为空表示当前位置
470 | * @param toLatitude 终点纬度
471 | * @param toLongitude 终点经度
472 | * @param isWGS84 为true表示使用GPS原始坐标系:wgs84,为false表示使用火星坐标系:gcj02
473 | * @param mode 出行模式 默认为:[TripMode.DRIVING_MODE]
474 | * - [TripMode.DRIVING_MODE] 驾车模式
475 | * - [TripMode.TRANSIT_MODE] 公交模式
476 | * - [TripMode.WALKING_MODE] 步行模式
477 | * - [TripMode.RIDING_MODE] 骑行模式
478 | * @param source 第三方调用应用名称。默认为:amap
479 | * @param isMarket 当检测到未安装目标App时,是否跳转到应用市场,默认为false,表示不跳转
480 | * @param marketPackage 当跳转到应用市场时,指定具体的应用市场包名。如:华为,小米,应用宝等各大应用市场,默认为空,表示不指定
481 | */
482 | @JvmStatic
483 | @JvmOverloads
484 | fun gotoAMapRoute(
485 | context: Context,
486 | fromLatitude: Double?,
487 | fromLongitude: Double?,
488 | toLatitude: Double,
489 | toLongitude: Double,
490 | isWGS84: Boolean = false,
491 | mode: Int = TripMode.DRIVING_MODE,
492 | source: String = "amap",
493 | isMarket: Boolean = false,
494 | marketPackage: String? = null
495 | ): Boolean {
496 | val dev = if (isWGS84) 1 else 0
497 | return if (fromLatitude == null || fromLongitude == null) {//起点经纬度为空时,表示从当前位置到终点位置
498 | val uri =
499 | "amapuri://route/plan/?sourceApplication=${source}&dlat=${toLatitude}&dlon=${toLongitude}&dev=${dev}&t=${mode}"
500 | gotoUri(context, AMAP_PACKAGE_NAME, Uri.parse(uri), isMarket, marketPackage)
501 | } else {
502 | val uri =
503 | "amapuri://route/plan/?sourceApplication=${source}&slat=${fromLatitude}&slon=${fromLongitude}&dLat=${toLatitude}&dlon=${toLongitude}&dev=${dev}&t=${mode}"
504 | gotoUri(context, AMAP_PACKAGE_NAME, Uri.parse(uri), isMarket, marketPackage)
505 | }
506 |
507 | }
508 |
509 | //---------------------------------------------
510 |
511 | /**
512 | * 跳转到百度地图导航
513 | *
514 | * 参见:[百度地图](http://lbsyun.baidu.com/index.php?title=uri/api/android)
515 | *
516 | * @param context
517 | * @param toLatitude 终点纬度
518 | * @param toLongitude 终点经度
519 | * @param coordinateType 坐标类型 默认为:[CoordinateType.GCJ02]
520 | * - [CoordinateType.GCJ02] 经国测局加密后的坐标系(火星坐标系)
521 | * - [CoordinateType.WGS84] GPS原始坐标系
522 | * - [CoordinateType.BD09LL] 百度经纬度坐标系
523 | * - [CoordinateType.BD09MC] 百度墨卡托坐标系
524 | * @param source 统计来源,默认取当前APK包名
525 | * @param isRoute 为true表示跳转到地图路线规划,为false表示跳转到导航
526 | * @param isMarket 当检测到未安装目标App时,是否跳转到应用市场,默认为false,表示不跳转
527 | * @param marketPackage 当跳转到应用市场时,指定具体的应用市场包名。如:华为,小米,应用宝等各大应用市场,默认为空,表示不指定
528 | */
529 | @JvmStatic
530 | @JvmOverloads
531 | fun gotoBaiduMap(
532 | context: Context,
533 | toLatitude: Double,
534 | toLongitude: Double,
535 | coordinateType: String = CoordinateType.GCJ02,
536 | source: String = context.packageName,
537 | isRoute: Boolean,
538 | isMarket: Boolean = false,
539 | marketPackage: String? = null
540 | ): Boolean {
541 | return if (isRoute) {
542 | gotoBaiduMapRoute(
543 | context,
544 | toLatitude,
545 | toLongitude,
546 | coordinateType,
547 | TripMode.DRIVING_MODE,
548 | source,
549 | isMarket,
550 | marketPackage
551 | )
552 | } else {
553 | gotoBaiduMapNavigation(
554 | context,
555 | toLatitude,
556 | toLongitude,
557 | coordinateType,
558 | source,
559 | isMarket,
560 | marketPackage
561 | )
562 | }
563 | }
564 |
565 | /**
566 | * 跳转到百度地图导航
567 | *
568 | * 参见:[百度地图](http://lbsyun.baidu.com/index.php?title=uri/api/android)
569 | *
570 | * @param context
571 | * @param toLatitude 终点纬度
572 | * @param toLongitude 终点经度
573 | * @param coordinateType 坐标类型 默认为:[CoordinateType.GCJ02]
574 | * - [CoordinateType.GCJ02] 经国测局加密后的坐标系(火星坐标系)
575 | * - [CoordinateType.WGS84] GPS原始坐标系
576 | * - [CoordinateType.BD09LL] 百度经纬度坐标系
577 | * - [CoordinateType.BD09MC] 百度墨卡托坐标系
578 | * @param source 统计来源,默认取当前APK包名
579 | * @param isMarket 当检测到未安装目标App时,是否跳转到应用市场,默认为false,表示不跳转
580 | * @param marketPackage 当跳转到应用市场时,指定具体的应用市场包名。如:华为,小米,应用宝等各大应用市场,默认为空,表示不指定
581 | */
582 | @JvmStatic
583 | @JvmOverloads
584 | fun gotoBaiduMapNavigation(
585 | context: Context,
586 | toLatitude: Double,
587 | toLongitude: Double,
588 | coordinateType: String = CoordinateType.GCJ02,
589 | source: String = context.packageName,
590 | isMarket: Boolean = false,
591 | marketPackage: String? = null
592 | ): Boolean {
593 | val uri =
594 | "baidumap://map/navi?location=${toLatitude},${toLongitude}&coord_type=${coordinateType}&type=DEFAULT&src=${source}"
595 | return gotoUri(context, BAIDU_MAP_PACKAGE_NAME, Uri.parse(uri), isMarket, marketPackage)
596 | }
597 |
598 | /**
599 | * 跳转到百度地图路线规划
600 | *
601 | * 参见:[百度地图](http://lbsyun.baidu.com/index.php?title=uri/api/android)
602 | *
603 | * @param context
604 | * @param toLatitude 终点纬度
605 | * @param toLongitude 终点经度
606 | * @param coordinateType 坐标类型 默认为:[CoordinateType.GCJ02]
607 | * - [CoordinateType.GCJ02] 经国测局加密后的坐标系(火星坐标系)
608 | * - [CoordinateType.WGS84] GPS原始坐标系
609 | * - [CoordinateType.BD09LL] 百度经纬度坐标系
610 | * - [CoordinateType.BD09MC] 百度墨卡托坐标系
611 | * @param mode 出行模式 默认为:[TripMode.DRIVING_MODE]
612 | * - [TripMode.DRIVING_MODE] 驾车模式
613 | * - [TripMode.TRANSIT_MODE] 公交模式
614 | * - [TripMode.WALKING_MODE] 步行模式
615 | * - [TripMode.RIDING_MODE] 骑行模式
616 | * @param source 统计来源,默认取当前APK包名
617 | * @param isMarket 当检测到未安装目标App时,是否跳转到应用市场,默认为false,表示不跳转
618 | * @param marketPackage 当跳转到应用市场时,指定具体的应用市场包名。如:华为,小米,应用宝等各大应用市场,默认为空,表示不指定
619 | */
620 | @JvmStatic
621 | @JvmOverloads
622 | fun gotoBaiduMapRoute(
623 | context: Context,
624 | toLatitude: Double,
625 | toLongitude: Double,
626 | coordinateType: String = CoordinateType.GCJ02,
627 | mode: Int = TripMode.DRIVING_MODE,
628 | source: String = context.packageName,
629 | isMarket: Boolean = false,
630 | marketPackage: String? = null
631 | ): Boolean {
632 | return gotoBaiduMapRoute(
633 | context,
634 | null,
635 | null,
636 | toLatitude,
637 | toLongitude,
638 | coordinateType,
639 | mode,
640 | source,
641 | isMarket,
642 | marketPackage
643 | )
644 | }
645 |
646 | /**
647 | * 跳转到百度地图路线规划
648 | *
649 | * 参见:[百度地图](http://lbsyun.baidu.com/index.php?title=uri/api/android)
650 | *
651 | * @param context
652 | * @param fromLatitude 起点纬度,为空表示当前位置
653 | * @param fromLongitude 起点经度,为空表示当前位置
654 | * @param toLatitude 终点纬度
655 | * @param toLongitude 终点经度
656 | * @param coordinateType 坐标类型 默认为:[CoordinateType.GCJ02]
657 | * - [CoordinateType.GCJ02] 经国测局加密后的坐标系(火星坐标系)
658 | * - [CoordinateType.WGS84] GPS原始坐标系
659 | * - [CoordinateType.BD09LL] 百度经纬度坐标系
660 | * - [CoordinateType.BD09MC] 百度墨卡托坐标系
661 | * @param mode 出行模式 默认为:[TripMode.DRIVING_MODE]
662 | * - [TripMode.DRIVING_MODE] 驾车模式
663 | * - [TripMode.TRANSIT_MODE] 公交模式
664 | * - [TripMode.WALKING_MODE] 步行模式
665 | * - [TripMode.RIDING_MODE] 骑行模式
666 | * @param source 统计来源,默认取当前APK包名
667 | * @param isMarket 当检测到未安装目标App时,是否跳转到应用市场,默认为false,表示不跳转
668 | * @param marketPackage 当跳转到应用市场时,指定具体的应用市场包名。如:华为,小米,应用宝等各大应用市场,默认为空,表示不指定
669 | */
670 | @JvmStatic
671 | @JvmOverloads
672 | fun gotoBaiduMapRoute(
673 | context: Context,
674 | fromLatitude: Double?,
675 | fromLongitude: Double?,
676 | toLatitude: Double,
677 | toLongitude: Double,
678 | coordinateType: String = CoordinateType.GCJ02,
679 | mode: Int = TripMode.DRIVING_MODE,
680 | source: String = context.packageName,
681 | isMarket: Boolean = false,
682 | marketPackage: String? = null
683 | ): Boolean {
684 | val tripMode = getBaiduTripMode(mode)
685 | return if (fromLatitude == null || fromLongitude == null) {//起点经纬度为空时,表示从当前位置到终点位置
686 | val uri =
687 | "baidumap://map/direction?destination=${toLatitude},${toLongitude}&coord_type=${coordinateType}&mode=${tripMode}&src=${source}"
688 | gotoUri(context, BAIDU_MAP_PACKAGE_NAME, Uri.parse(uri), isMarket, marketPackage)
689 | } else {
690 | val uri =
691 | "baidumap://map/direction?origin=${fromLatitude},${fromLongitude}&destination=${toLatitude},${toLongitude}&coord_type=${coordinateType}&mode=${tripMode}&src=${source}"
692 | gotoUri(context, BAIDU_MAP_PACKAGE_NAME, Uri.parse(uri), isMarket, marketPackage)
693 | }
694 |
695 | }
696 |
697 | /**
698 | * 获取出行模式
699 | */
700 | @JvmStatic
701 | private fun getBaiduTripMode(mode: Int) = when (mode) {
702 | TripMode.DRIVING_MODE -> TripMode.BAIDU_DRIVING_MODE
703 | TripMode.TRANSIT_MODE -> TripMode.BAIDU_TRANSIT_MODE
704 | TripMode.WALKING_MODE -> TripMode.BAIDU_WALKING_MODE
705 | TripMode.RIDING_MODE -> TripMode.BAIDU_RIDING_MODE
706 | else -> TripMode.BAIDU_DRIVING_MODE
707 | }
708 |
709 | //---------------------------------------------
710 | /**
711 | * 跳转到腾讯地图线路规划
712 | *
713 | * 参见:[腾讯地图 - 导航和路线规划](https://lbs.qq.com/webApi/uriV1/uriGuide/uriMobileRoute)
714 | *
715 | * @param context
716 | * @param toLatitude 终点纬度
717 | * @param toLongitude 终点经度
718 | * @param referer 腾讯地图开发者申请的AppKey,默认为 [DEFAULT_REFERER]
719 | * @param isMarket 当检测到未安装目标App时,是否跳转到应用市场,默认为false,表示不跳转
720 | * @param marketPackage 当跳转到应用市场时,指定具体的应用市场包名。如:华为,小米,应用宝等各大应用市场,默认为空,表示不指定
721 | */
722 | @JvmStatic
723 | @JvmOverloads
724 | fun gotoTencentMap(
725 | context: Context,
726 | toLatitude: Double,
727 | toLongitude: Double,
728 | referer: String = DEFAULT_REFERER,
729 | isMarket: Boolean = false,
730 | marketPackage: String? = null
731 | ): Boolean {
732 | return gotoTencentMapRoute(
733 | context,
734 | null,
735 | null,
736 | toLatitude,
737 | toLongitude,
738 | TripMode.DRIVING_MODE,
739 | referer,
740 | isMarket,
741 | marketPackage
742 | )
743 | }
744 |
745 | /**
746 | * 跳转到腾讯地图线路规划
747 | *
748 | * 参见:[腾讯地图 - 导航和路线规划](https://lbs.qq.com/webApi/uriV1/uriGuide/uriMobileRoute)
749 | *
750 | * @param context
751 | * @param fromLatitude 起点纬度,为空表示当前位置
752 | * @param fromLongitude 起点经度,为空表示当前位置
753 | * @param toLatitude 终点纬度
754 | * @param toLongitude 终点经度
755 | * @param mode 出行模式 默认为:[TripMode.DRIVING_MODE]
756 | * - [TripMode.DRIVING_MODE] 驾车模式
757 | * - [TripMode.TRANSIT_MODE] 公交模式
758 | * - [TripMode.WALKING_MODE] 步行模式
759 | * - [TripMode.RIDING_MODE] 骑行模式
760 | * @param referer 腾讯地图开发者申请的AppKey,默认为 [DEFAULT_REFERER]
761 | * @param isMarket 当检测到未安装目标App时,是否跳转到应用市场,默认为false,表示不跳转
762 | * @param marketPackage 当跳转到应用市场时,指定具体的应用市场包名。如:华为,小米,应用宝等各大应用市场,默认为空,表示不指定
763 | */
764 | @JvmStatic
765 | @JvmOverloads
766 | fun gotoTencentMapRoute(
767 | context: Context,
768 | fromLatitude: Double?,
769 | fromLongitude: Double?,
770 | toLatitude: Double,
771 | toLongitude: Double,
772 | mode: Int = TripMode.DRIVING_MODE,
773 | referer: String = DEFAULT_REFERER,
774 | isMarket: Boolean = false,
775 | marketPackage: String? = null
776 | ): Boolean {
777 | val tripMode = getTencentTripMode(mode)
778 | return if (fromLatitude == null || fromLongitude == null) {//起点经纬度为空时,表示从当前位置到终点位置
779 | val uri =
780 | "qqmap://map/routeplan?type=${tripMode}&tocoord=${toLatitude},${toLongitude}&referer=${referer}"
781 | gotoUri(context, TENCENT_MAP_PACKAGE_NAME, Uri.parse(uri), isMarket, marketPackage)
782 | } else {
783 | val uri =
784 | "qqmap://map/routeplan?type=${tripMode}&fromcoord=${fromLatitude},${fromLongitude}&tocoord=${toLatitude},${toLongitude}&referer=${referer}"
785 | gotoUri(context, TENCENT_MAP_PACKAGE_NAME, Uri.parse(uri), isMarket, marketPackage)
786 | }
787 |
788 | }
789 |
790 | /**
791 | * 获取出行模式
792 | */
793 | @JvmStatic
794 | private fun getTencentTripMode(mode: Int) = when (mode) {
795 | TripMode.DRIVING_MODE -> TripMode.TENCENT_DRIVING_MODE
796 | TripMode.TRANSIT_MODE -> TripMode.TENCENT_TRANSIT_MODE
797 | TripMode.WALKING_MODE -> TripMode.TENCENT_WALKING_MODE
798 | TripMode.RIDING_MODE -> TripMode.TENCENT_RIDING_MODE
799 | else -> TripMode.TENCENT_DRIVING_MODE
800 | }
801 |
802 | /**
803 | * 设置腾讯地图默认使用的AppKey
804 | * @param referer 腾讯地图开发者申请的AppKey
805 | */
806 | @JvmStatic
807 | fun setTencentMapDefaultReferer(referer: String) {
808 | DEFAULT_REFERER = referer
809 | }
810 |
811 | //---------------------------------------------
812 |
813 | /**
814 | * 跳转到谷歌地图导航
815 | *
816 | * 参见:[谷歌地图](https://developers.google.cn/maps/documentation/urls/android-intents)
817 | *
818 | * @param toLatitude 终点纬度
819 | * @param toLongitude 终点经度
820 | * @param isMarket 当检测到未安装目标App时,是否跳转到应用市场,默认为false,表示不跳转
821 | * @param marketPackage 当跳转到应用市场时,指定具体的应用市场包名。如:华为,小米,应用宝等各大应用市场,默认为空,表示不指定
822 | */
823 | @JvmStatic
824 | @JvmOverloads
825 | fun gotoGoogleMap(
826 | context: Context,
827 | toLatitude: Double,
828 | toLongitude: Double,
829 | isMarket: Boolean = false,
830 | marketPackage: String? = null
831 | ): Boolean {
832 | return gotoGoogleMapNavigation(
833 | context,
834 | toLatitude,
835 | toLongitude,
836 | TripMode.DRIVING_MODE,
837 | isMarket,
838 | marketPackage
839 | )
840 | }
841 |
842 | /**
843 | * 跳转到谷歌地图导航
844 | *
845 | * 参见:[谷歌地图](https://developers.google.cn/maps/documentation/urls/android-intents)
846 | *
847 | * @param toLatitude 终点纬度
848 | * @param toLongitude 终点经度
849 | * @param mode 出行模式 默认为:[TripMode.DRIVING_MODE]
850 | * - [TripMode.DRIVING_MODE] 驾车模式
851 | * - [TripMode.TRANSIT_MODE] 公交模式
852 | * - [TripMode.WALKING_MODE] 步行模式
853 | * - [TripMode.RIDING_MODE] 骑行模式
854 | * @param isMarket 当检测到未安装目标App时,是否跳转到应用市场,默认为false,表示不跳转
855 | * @param marketPackage 当跳转到应用市场时,指定具体的应用市场包名。如:华为,小米,应用宝等各大应用市场,默认为空,表示不指定
856 | */
857 | @JvmStatic
858 | @JvmOverloads
859 | fun gotoGoogleMapNavigation(
860 | context: Context,
861 | toLatitude: Double,
862 | toLongitude: Double,
863 | mode: Int = TripMode.DRIVING_MODE,
864 | isMarket: Boolean = false,
865 | marketPackage: String? = null
866 | ): Boolean {
867 | val tripMode = getGoogleTripMode(mode)
868 | val uri = "google.navigation:q=${toLatitude},${toLongitude}&mode=${tripMode}"
869 | return gotoUri(context, GOOGLE_MAP_PACKAGE_NAME, Uri.parse(uri), isMarket, marketPackage)
870 | }
871 |
872 | /**
873 | * 获取出行模式
874 | */
875 | @JvmStatic
876 | private fun getGoogleTripMode(mode: Int) = when (mode) {
877 | TripMode.DRIVING_MODE -> TripMode.GOOGLE_DRIVING_MODE
878 | TripMode.TRANSIT_MODE -> TripMode.GOOGLE_TRANSIT_MODE
879 | TripMode.WALKING_MODE -> TripMode.GOOGLE_WALKING_MODE
880 | TripMode.RIDING_MODE -> TripMode.GOOGLE_RIDING_MODE
881 | else -> TripMode.GOOGLE_DRIVING_MODE
882 | }
883 |
884 | //---------------------------------------------
885 |
886 | /**
887 | * 跳转到指定App的Uri
888 | * @param context
889 | * @param packageName 跳转目标App的包名
890 | * @param uri 跳转目标App的Uri
891 | * @param isMarket 当检测到未安装目标App时,是否跳转到应用市场,默认为false,表示不跳转
892 | * @param marketPackage 当跳转到应用市场时,指定具体的应用市场包名。如:华为,小米,应用宝等各大应用市场,默认为空,表示不指定
893 | */
894 | @JvmStatic
895 | private fun gotoUri(
896 | context: Context,
897 | packageName: String,
898 | uri: Uri,
899 | isMarket: Boolean,
900 | marketPackage: String? = null
901 | ): Boolean {
902 | try {
903 | Log.d(TAG, "Uri: $uri")
904 | val intent = Intent(Intent.ACTION_VIEW, uri)
905 | intent.addCategory(Intent.CATEGORY_DEFAULT)
906 | intent.setPackage(packageName)
907 | if (intent.resolveActivity(context.packageManager) != null) {
908 | context.startActivity(intent)
909 | return true
910 | } else {
911 | Log.w(TAG, "An App with Identifier '${packageName}' is not available.")
912 | if (isMarket) {
913 | // 是否跳转到应用市场
914 | return gotoMarket(context, packageName, marketPackage)
915 | }
916 | }
917 | } catch (e: Exception) {
918 | Log.w(TAG, e)
919 | }
920 | return false
921 | }
922 |
923 | /**
924 | * 跳转到应用市场App详情
925 | * @param context
926 | * @param packageName 应用市场目标App详情App包名
927 | * @param marketPackage 当跳转到应用市场时,指定具体的应用市场包名。如:华为,小米,应用宝等各大应用市场,默认为空,表示不指定
928 | */
929 | @JvmStatic
930 | private fun gotoMarket(
931 | context: Context,
932 | packageName: String,
933 | marketPackage: String? = null
934 | ): Boolean {
935 | try {
936 | val marketUri = Uri.parse("market://details?id=${packageName}")
937 | val marketIntent = Intent(Intent.ACTION_VIEW, marketUri)
938 | marketIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
939 | if (!TextUtils.isEmpty(marketPackage)) {
940 | marketIntent.setPackage(marketPackage)
941 | }
942 | context.startActivity(marketIntent)
943 | return true
944 | } catch (e: Exception) {
945 | Log.w(TAG, e)
946 | }
947 | return false
948 | }
949 |
950 | //---------------------------------------------
951 |
952 | /**
953 | * 圆周率π [Math.PI]
954 | */
955 | private const val PI = 3.14159265358979323846
956 |
957 | /**
958 | * 圆周率转换量
959 | */
960 | private const val X_PI = PI * 3000.0 / 180.0
961 |
962 | /**
963 | * 卫星椭球坐标投影到平面地图坐标系的投影因子
964 | */
965 | private const val A = 6378245.0
966 |
967 | /**
968 | * 椭球的偏心率
969 | */
970 | private const val EE = 0.00669342162296594323
971 |
972 | /**
973 | * 百度坐标系 (BD-09ll) 与 火星坐标系 (GCJ-02)的转换
974 | * 即 百度 转 谷歌、高德
975 | * @param latitude 纬度
976 | * @param longitude 经度
977 | * @return [LatLng]
978 | */
979 | @JvmStatic
980 | fun bd09llToGCJ02(latitude: Double, longitude: Double): LatLng {
981 | val x = longitude - 0.0065
982 | val y = latitude - 0.006
983 | val z = sqrt(x * x + y * y) - 0.00002 * sin(y * X_PI)
984 | val theta = atan2(y, x) - 0.000003 * cos(x * X_PI)
985 | val ggLat = z * sin(theta)
986 | val ggLng = z * cos(theta)
987 | return LatLng(ggLat, ggLng)
988 | }
989 |
990 | /**
991 | * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09LL) 的转换
992 | * 即谷歌、高德 转 百度
993 | * @param latitude 纬度
994 | * @param longitude 经度
995 | * @return [LatLng]
996 | */
997 | @JvmStatic
998 | fun gcj02ToBD09LL(latitude: Double, longitude: Double): LatLng {
999 | val z = sqrt(longitude * longitude + latitude * latitude) + 0.00002 * sin(latitude * X_PI)
1000 | val theta = atan2(latitude, longitude) + 0.000003 * cos(longitude * X_PI)
1001 | val bdLat = z * sin(theta) + 0.006
1002 | val bdLng = z * cos(theta) + 0.0065
1003 | return LatLng(bdLat, bdLng)
1004 | }
1005 |
1006 | /**
1007 | * WGS-84转 GCJ-02
1008 | * @param latitude 纬度
1009 | * @param longitude 经度
1010 | * @return [LatLng]
1011 | */
1012 | @JvmStatic
1013 | fun wgs84ToGCJ02(latitude: Double, longitude: Double): LatLng {
1014 | if (outOfChina(latitude, longitude)) {
1015 | return LatLng(latitude, longitude)
1016 | }
1017 | var dLat = transformLat(latitude - 35.0, longitude - 105.0)
1018 | var dLng = transformLng(latitude - 35.0, longitude - 105.0)
1019 | val radLat = latitude / 180.0 * PI
1020 | var magic = sin(radLat)
1021 | magic = 1 - EE * magic * magic
1022 | val sqrtMagic = sqrt(magic)
1023 | dLat = (dLat * 180.0) / ((A * (1 - EE)) / (magic * sqrtMagic) * PI)
1024 | dLng = (dLng * 180.0) / (A / sqrtMagic * cos(radLat) * PI)
1025 | val ggLat = latitude + dLat
1026 | val ggLng = longitude + dLng
1027 | return LatLng(ggLat, ggLng)
1028 | }
1029 |
1030 | /**
1031 | * GCJ-02 转换为 WGS-84
1032 | * @param latitude 纬度
1033 | * @param longitude 经度
1034 | * @return [LatLng]
1035 | */
1036 | @JvmStatic
1037 | fun gcj02ToWGS84(latitude: Double, longitude: Double): LatLng {
1038 | if (outOfChina(latitude, longitude)) {
1039 | return LatLng(latitude, longitude)
1040 | }
1041 | var dLat = transformLat(latitude - 35.0, longitude - 105.0)
1042 | var dLng = transformLng(latitude - 35.0, longitude - 105.0)
1043 | val radLat = latitude / 180.0 * PI
1044 | var magic = sin(radLat)
1045 | magic = 1 - EE * magic * magic
1046 | val sqrtMagic = sqrt(magic)
1047 | dLat = (dLat * 180.0) / ((A * (1 - EE)) / (magic * sqrtMagic) * PI)
1048 | dLng = (dLng * 180.0) / (A / sqrtMagic * cos(radLat) * PI)
1049 | val ggLat = latitude + dLat
1050 | val ggLng = longitude + dLng
1051 | return LatLng(latitude * 2 - ggLat, longitude * 2 - ggLng)
1052 | }
1053 |
1054 | /**
1055 | * 转换坐标纬度
1056 | * @param latitude 纬度
1057 | * @param longitude 经度
1058 | *
1059 | */
1060 | @JvmStatic
1061 | private fun transformLat(latitude: Double, longitude: Double): Double {
1062 | var ret = -100.0 + 2.0 * longitude + 3.0 * latitude + 0.2 * latitude * latitude + 0.1 * longitude * latitude + 0.2 * sqrt(abs(longitude))
1063 | ret += (20.0 * sin(6.0 * longitude * PI) + 20.0 * sin(2.0 * longitude * PI)) * 2.0 / 3.0
1064 | ret += (20.0 * sin(latitude * PI) + 40.0 * sin(latitude / 3.0 * PI)) * 2.0 / 3.0
1065 | ret += (160.0 * sin(latitude / 12.0 * PI) + 320 * sin(latitude * PI / 30.0)) * 2.0 / 3.0
1066 | return ret
1067 | }
1068 |
1069 | /**
1070 | * 转换坐标经度
1071 | * @param latitude 纬度
1072 | * @param longitude 经度
1073 | *
1074 | */
1075 | @JvmStatic
1076 | private fun transformLng(latitude: Double, longitude: Double): Double {
1077 | var ret = 300.0 + longitude + 2.0 * latitude + 0.1 * longitude * longitude + 0.1 * longitude * latitude + 0.1 * sqrt(abs(longitude))
1078 | ret += (20.0 * sin(6.0 * longitude * PI) + 20.0 * sin(2.0 * longitude * PI)) * 2.0 / 3.0
1079 | ret += (20.0 * sin(longitude * PI) + 40.0 * sin(longitude / 3.0 * PI)) * 2.0 / 3.0
1080 | ret += (150.0 * sin(longitude / 12.0 * PI) + 300.0 * sin(longitude / 30.0 * PI)) * 2.0 / 3.0
1081 | return ret
1082 | }
1083 |
1084 | /**
1085 | * 判断是否在国内,不在国内则不做偏移
1086 | * @param latitude 纬度
1087 | * @param longitude 经度
1088 | * @return
1089 | */
1090 | @JvmStatic
1091 | private fun outOfChina(latitude: Double, longitude: Double): Boolean {
1092 | return (longitude < 72.004 || longitude > 137.8347) || (latitude < 0.8293 || latitude > 55.8271)
1093 | }
1094 |
1095 | //---------------------------------------------
1096 | }
1097 |
1098 |
--------------------------------------------------------------------------------
/maphelper/src/test/java/com/king/map/maphelper/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.king.map.maphelper
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/mkdocs.yml:
--------------------------------------------------------------------------------
1 | # Project information
2 | site_name: MapHelper
3 | site_url: https://jenly1314.github.io/MapHelper/
4 | site_description: "MapHelper for Android"
5 | site_author: Jenly
6 | remote_branch: gh-pages
7 | edit_uri: ""
8 |
9 | # Repository
10 | repo_name: MapHelper
11 | repo_url: https://github.com/jenly1314/MapHelper
12 |
13 | # Copyright
14 | copyright: 'Copyright © 2016 - 2024 Jenly'
15 |
16 | # Configuration
17 | theme:
18 | name: 'material'
19 | favicon: https://jenly1314.github.io/favicon.png
20 | logo: https://jenly1314.github.io/medias/logo.png
21 | icon:
22 | repo: fontawesome/brands/github
23 | language: zh
24 | palette:
25 | - media: "(prefers-color-scheme: light)"
26 | scheme: default
27 | primary: teal
28 | accent: blue
29 | toggle:
30 | icon: octicons/sun-24
31 | name: "切换到深色模式"
32 | - media: "(prefers-color-scheme: dark)"
33 | scheme: slate
34 | primary: teal
35 | accent: blue
36 | toggle:
37 | icon: octicons/moon-24
38 | name: "切换到浅色模式"
39 | features:
40 | - navigation.instant
41 | - navigation.instant.progress
42 | - navigation.tabs
43 | - content.code.copy
44 |
45 | extra:
46 | social:
47 | - icon: material/home-circle
48 | link: https://jenly1314.github.io/
49 | - icon: simple/github
50 | link: https://github.com/jenly1314/
51 | - icon: simple/gitee
52 | link: https://gitee.com/jenly1314/
53 | - icon: fontawesome/solid/paper-plane
54 | link: mailto:jenly1314@gmail.com
55 |
56 | markdown_extensions:
57 | - smarty
58 | - footnotes
59 | - meta
60 | - toc:
61 | permalink: true
62 | - attr_list
63 | - pymdownx.betterem:
64 | smart_enable: all
65 | - pymdownx.caret
66 | - pymdownx.emoji:
67 | emoji_index: !!python/name:materialx.emoji.twemoji
68 | emoji_generator: !!python/name:materialx.emoji.to_svg
69 | - pymdownx.inlinehilite
70 | - pymdownx.magiclink
71 | - pymdownx.smartsymbols
72 | - pymdownx.superfences
73 | - pymdownx.tilde
74 | - pymdownx.tabbed:
75 | alternate_style: true
76 | - tables
77 |
78 | # Plugins
79 | plugins:
80 | - search
81 |
82 | nav:
83 | - '概览': index.md
84 | - 'API文档': api/index.html
85 | - '版本日志': changelog.md
86 |
87 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | gradlePluginPortal()
4 | google()
5 | mavenCentral()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 |
16 | rootProject.name='MapHelper'
17 | include ':app'
18 | include ':maphelper'
19 |
--------------------------------------------------------------------------------
/versions.gradle:
--------------------------------------------------------------------------------
1 | //App
2 | def app_version = [:]
3 | app_version.versionCode = 3
4 | app_version.versionName = "1.2.0"
5 | ext.app_version = app_version
6 |
7 | //build version
8 | def build_versions = [:]
9 | build_versions.minSdk = 16
10 | build_versions.targetSdk = 32
11 | build_versions.compileSdk = 32
12 | build_versions.buildTools = "32.0.0"
13 | ext.build_versions = build_versions
14 |
15 | // App dependencies
16 | def versions = [:]
17 |
18 | versions.bintray_release = "0.9.2"
19 | versions.mavenPublish = '0.22.0'
20 | versions.dokka = "1.7.20"
21 | versions.gradle = "7.2.1"
22 | versions.kotlin = "1.7.20"
23 | versions.coreKtx = "1.7.0"
24 | versions.appcompat = "1.2.0"
25 | versions.constraintlayout = "2.0.4"
26 |
27 | versions.junit = "4.13.2"
28 | versions.androidExtJunit = "1.1.3"
29 | versions.espressoCore = "3.4.0"
30 |
31 | ext.versions = versions
--------------------------------------------------------------------------------