├── .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 | ![Image](app/src/main/ic_launcher-playstore.png) 4 | 5 | [![MavenCentral](https://img.shields.io/maven-central/v/com.github.jenly1314/maphelper?logo=sonatype)](https://repo1.maven.org/maven2/com/github/jenly1314/MapHelper) 6 | [![JitPack](https://img.shields.io/jitpack/v/github/jenly1314/MapHelper?logo=jitpack)](https://jitpack.io/#jenly1314/MapHelper) 7 | [![CI](https://img.shields.io/github/actions/workflow/status/jenly1314/MapHelper/build.yml?logo=github)](https://github.com/jenly1314/MapHelper/actions/workflows/build.yml) 8 | [![Download](https://img.shields.io/badge/download-APK-brightgreen?logo=github)](https://raw.githubusercontent.com/jenly1314/MapHelper/master/app/release/app-release.apk) 9 | [![API](https://img.shields.io/badge/API-16%2B-brightgreen?logo=android)](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) 10 | [![License](https://img.shields.io/github/license/jenly1314/MapHelper?logo=open-source-initiative)](https://opensource.org/licenses/mit) 11 | 12 | MapHelper for Android 是一个整合了高德地图、百度地图、腾讯地图、谷歌地图等相关路线规划和导航的地图帮助类库。 13 | 14 | ## 功能介绍 15 | - ✅ 简单易用,一句代码实现 16 | - ✅ 地图路线规划/导航 17 | - ✅ **GCJ-02** / **WGS-84** / **BD09LL** 等相关坐标系互转 18 | 19 | ## 效果展示 20 | ![Image](GIF.gif) 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 | ![footer](https://jenly1314.github.io/page/footer.svg) 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 |