├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── android ├── .gitignore ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── libs │ └── AMap_Location_V4.9.0_20200228.jar ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── amap │ └── location │ └── amaplocationflutterplugin │ ├── AMapLocationClientImpl.java │ ├── AmapLocationFlutterPlugin.java │ └── Utils.java ├── example ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── amap │ │ │ │ └── location │ │ │ │ └── amaplocationflutterpluginexample │ │ │ │ └── MainActivity.java │ │ │ └── res │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── debug.keystore ├── ios │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ ├── Flutter.podspec │ │ └── Release.xcconfig │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── Runner │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── main.m ├── lib │ └── main.dart ├── pubspec.yaml └── test │ └── widget_test.dart ├── ios ├── .gitignore ├── Assets │ └── .gitkeep ├── Classes │ ├── AmapFlutterStreamManager.h │ ├── AmapFlutterStreamManager.m │ ├── AmapLocationFlutterPlugin.h │ └── AmapLocationFlutterPlugin.m └── amap_location_flutter_plugin.podspec ├── lib ├── amap_location_flutter_plugin.dart ├── amap_location_option.dart └── generated │ └── i18n.dart ├── pubspec.yaml └── res └── values └── strings_en.arb /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | 39 | # Keystore files 40 | *.jks 41 | .DS_Store 42 | 43 | .idea 44 | .packages 45 | pubspec.lock 46 | .dart_tool 47 | example/.flutter-plugins-dependencies 48 | example/ios/Flutter/.last_build_id 49 | example/ios/Flutter/flutter_export_environment.sh 50 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.4 2 | * add platform condition for method getSystemAccuracyAuthorization to avoid android crash; 3 | 4 | ## 0.1.3 5 | * fix Android cityCode and adCode return error 6 | * add iOS cityCode 7 | 8 | ## 0.1.2 9 | * update the dependent version number of the fluent SDK 10 | 11 | ## 0.1.1 12 | * new features of adaptive ios14 positioning 13 | 14 | ## 0.1.0 15 | * init release 16 | 17 | 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright <2020> 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 前述 2 | 3 | 1. 高德定位Flutter插件 4 | 2. [高德开放平台官网](https://lbs.amap.com/api/)分别申请[Android端](https://lbs.amap.com/api/android-location-sdk/guide/create-project/get-key/)和[iOS端](https://lbs.amap.com/api/ios-location-sdk/guide/create-project/get-key)的key 5 | 3. 如需了解高德定位SDK的相关功能,请参阅[Android定位SDK开发指南](http://lbs.amap.com/api/android-location-sdk/locationsummary/)和[iOS定位SDK开发指南](https://lbs.amap.com/api/ios-location-sdk/summary/) 6 | 4. 高德定位Flutter插件内部没有集成动态申请权限插件,您可根据自身需要添加相应的权限申请插件。可以参考[permisson_handler](https://github.com/Baseflow/flutter-permission-handler)插件 7 | 8 | ## 使用高德定位Flutter插件 9 | ### 集成高德定位Flutter插件 10 | #### 集成方式: 11 | * 方式一 github方引用 12 | 1. 在pubspect.yaml的dependencies里添加如下代码 13 | ``` Java 14 | amap_location_flutter_plugin: 15 | git: 16 | url: https://github.com/amap-demo/amap-location-flutter.git 17 | ``` 18 | 2. 执行``flutter packages get``等待插件下载完成 19 | * 方式二 下载到本地引用 20 | 1. 下载高德定位Flutter插件源码 21 | 2. 在本地工程目录下创建plugins目录,将下载的目录复制到plugins目录下 22 | 3. 在pubspect.yaml的dependencies里添加如下代码 23 | ``` Java 24 | amap_location_flutter_plugin: 25 | path: plugins/amap-location-flutter 26 | ``` 27 | 4. 执行``flutter packages get``等待插件现在完成 28 | 29 | #### 常见问题: 30 | 1、[在iOS设备上运行或者运行iOS工程遇到: `Invalid `Podfile` file: cannot load such file - /flutter/packages/flutter_tools/bin/podhelper`](https://github.com/flutter/flutter/issues/59522) 31 | ``` 32 | $ rm ios/Podfile 33 | $ flutter build ios 34 | ``` 35 | 36 | ### 在需要的定位功能的页面中引入定位Flutter插件的dart类 37 | ``` Dart 38 | import 'package:amap_location_flutter_plugin/amap_location_flutter_plugin.dart'; 39 | import 'package:amap_location_flutter_plugin/amap_location_option.dart'; 40 | ``` 41 | ## 接口说明 42 | 43 | ### 设置APIKey 44 | ``` Dart 45 | ///设置Android和iOS的apikey,建议在开始定位之前设置 46 | ///[androidKey] Android平台的key 47 | ///[iosKey] ios平台的key 48 | static void setApiKey(String androidKey, String iosKey) 49 | ``` 50 | ### 申请定位权限 51 | ``` Dart 52 | /// 申请定位权限 53 | /// 授予定位权限返回true, 否则返回false 54 | Future requestLocationPermission() 55 | ``` 56 | 57 | ### 设置定位参数 58 | ``` Dart 59 | /// 设置定位参数 60 | void setLocationOption(AMapLocationOption locationOption) 61 | ``` 62 | > 将您设置的参数传递到原生端对外接口,目前支持以下定位参数 63 | ``` Dart 64 | /// 是否需要地址信息,默认true 65 | bool needAddress = true; 66 | 67 | ///逆地理信息语言类型 68 | ///默认[GeoLanguage.DEFAULT] 自动适配 69 | ///可选值: 70 | ///[GeoLanguage.DEFAULT] 自动适配 71 | ///[GeoLanguage.EN] 英文 72 | ///[GeoLanguage.ZH] 中文 73 | GeoLanguage geoLanguage; 74 | 75 | ///是否单次定位 76 | ///默认值:false 77 | bool onceLocation = false; 78 | 79 | ///Android端定位模式, 只在Android系统上有效> 80 | ///默认值:[AMapLocationMode.Hight_Accuracy] 81 | ///可选值: 82 | ///[AMapLocationMode.Battery_Saving] 83 | ///[AMapLocationMode.Device_Sensors] 84 | ///[AMapLocationMode.Hight_Accuracy] 85 | AMapLocationMode locationMode; 86 | 87 | ///Android端定位间隔 88 | ///单位:毫秒 89 | ///默认:2000毫秒 90 | int locationInterval = 2000; 91 | 92 | ///iOS端是否允许系统暂停定位 93 | ///默认:false 94 | bool pausesLocationUpdatesAutomatically = false; 95 | 96 | /// iOS端期望的定位精度, 只在iOS端有效 97 | /// 默认值:最高精度 98 | /// 可选值: 99 | /// [DesiredAccuracy.Best] 最高精度 100 | /// [DesiredAccuracy.BestForNavigation] 适用于导航场景的高精度 101 | /// [DesiredAccuracy.NearestTenMeters] 10米 102 | /// [DesiredAccuracy.Kilometer] 1000米 103 | /// [DesiredAccuracy.ThreeKilometers] 3000米< 104 | DesiredAccuracy desiredAccuracy = DesiredAccuracy.Best; 105 | 106 | /// iOS端定位最小更新距离 107 | /// 单位:米 108 | /// 默认值:-1,不做限制 109 | double distanceFilter = -1; 110 | ``` 111 | ### 开始定位 112 | ``` Dart 113 | void startLocation() 114 | ``` 115 | ### 停止定位 116 | ``` Dart 117 | void stopLocation() 118 | ``` 119 | ### 销毁定位 120 | > 高德定位Flutter插件,支持多实例,请在weidet执行dispose()时调用当前定位插件的销毁方法 121 | ``` Dart 122 | void destroy() 123 | ``` 124 | ### 定位结果获取 125 | > 原生端以键值对map的形式回传定位结果到Flutter端, 通过onLoationChanged返回定位结果 126 | ``` Dart 127 | Stream> onLocationChanged() 128 | ``` 129 | > 注册定位结果监听 130 | ``` Dart 131 | _locationPlugin 132 | .onLocationChanged() 133 | .listen((Map result) { 134 | ///result即为定位结果 135 | } 136 | ``` 137 | 138 | 139 | ## Getting Started 140 | 141 | For help getting started with Flutter, view our online 142 | [documentation](https://flutter.io/). 143 | 144 | For help on editing plugin code, view the [documentation](https://flutter.io/developing-packages/#edit-plugin-package). 145 | 146 | 147 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.amap.location.amaplocationflutterplugin' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:3.5.1' 12 | } 13 | } 14 | 15 | rootProject.allprojects { 16 | repositories { 17 | google() 18 | jcenter() 19 | } 20 | } 21 | 22 | apply plugin: 'com.android.library' 23 | 24 | android { 25 | compileSdkVersion 28 26 | 27 | defaultConfig { 28 | minSdkVersion 16 29 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 30 | } 31 | lintOptions { 32 | disable 'InvalidPackage' 33 | } 34 | 35 | dependencies { 36 | implementation fileTree(dir: 'libs', include: ['*.jar']) 37 | // compile 'com.amap.api:location:4.9.0' 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableJetifier=true 3 | #android.useAndroidX=true 4 | #android.enableR8=true 5 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip 6 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /android/libs/AMap_Location_V4.9.0_20200228.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/android/libs/AMap_Location_V4.9.0_20200228.jar -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'amap_location_flutter_plugin' 2 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /android/src/main/java/com/amap/location/amaplocationflutterplugin/AMapLocationClientImpl.java: -------------------------------------------------------------------------------- 1 | package com.amap.location.amaplocationflutterplugin; 2 | 3 | import android.content.Context; 4 | import android.util.Log; 5 | 6 | import com.amap.api.location.AMapLocation; 7 | import com.amap.api.location.AMapLocationClient; 8 | import com.amap.api.location.AMapLocationClientOption; 9 | import com.amap.api.location.AMapLocationListener; 10 | 11 | import java.util.Map; 12 | 13 | import io.flutter.plugin.common.EventChannel; 14 | 15 | /** 16 | * @author whm 17 | * @date 2020-04-16 15:49 18 | * @mail hongming.whm@alibaba-inc.com 19 | */ 20 | public class AMapLocationClientImpl implements AMapLocationListener { 21 | 22 | private Context mContext; 23 | private AMapLocationClientOption locationOption = new AMapLocationClientOption(); 24 | private AMapLocationClient locationClient = null; 25 | private EventChannel.EventSink mEventSink; 26 | 27 | private String mPluginKey; 28 | 29 | public AMapLocationClientImpl(Context context, String pluginKey, EventChannel.EventSink eventSink) { 30 | mContext = context; 31 | mPluginKey = pluginKey; 32 | mEventSink = eventSink; 33 | if(null == locationClient) { 34 | locationClient = new AMapLocationClient(context); 35 | } 36 | } 37 | 38 | /** 39 | * 开始定位 40 | */ 41 | public void startLocation() { 42 | if (null == locationClient) { 43 | locationClient = new AMapLocationClient(mContext); 44 | } 45 | if (null != locationOption) { 46 | locationClient.setLocationOption(locationOption); 47 | } 48 | locationClient.setLocationListener(this); 49 | locationClient.startLocation(); 50 | } 51 | 52 | 53 | /** 54 | * 停止定位 55 | */ 56 | public void stopLocation() { 57 | if (null != locationClient) { 58 | locationClient.stopLocation(); 59 | locationClient.onDestroy(); 60 | locationClient = null; 61 | } 62 | } 63 | 64 | public void destroy() { 65 | if(null != locationClient) { 66 | locationClient.onDestroy(); 67 | locationClient = null; 68 | } 69 | } 70 | /** 71 | * 定位回调 72 | * 73 | * @param location 74 | */ 75 | @Override 76 | public void onLocationChanged(AMapLocation location) { 77 | if (null == mEventSink) { 78 | return; 79 | } 80 | Map result = Utils.buildLocationResultMap(location); 81 | result.put("pluginKey", mPluginKey); 82 | mEventSink.success(result); 83 | } 84 | 85 | 86 | /** 87 | * 设置定位参数 88 | * 89 | * @param optionMap 90 | */ 91 | public void setLocationOption(Map optionMap) { 92 | if (null == locationOption) { 93 | locationOption = new AMapLocationClientOption(); 94 | } 95 | 96 | if (optionMap.containsKey("locationInterval")) { 97 | locationOption.setInterval(((Integer) optionMap.get("locationInterval")).longValue()); 98 | } 99 | 100 | if (optionMap.containsKey("needAddress")) { 101 | locationOption.setNeedAddress((boolean) optionMap.get("needAddress")); 102 | } 103 | 104 | if (optionMap.containsKey("locationMode")) { 105 | try { 106 | locationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.values()[(int) optionMap.get("locationMode")]); 107 | } catch (Throwable e) { 108 | } 109 | } 110 | 111 | if (optionMap.containsKey("geoLanguage")) { 112 | locationOption.setGeoLanguage(AMapLocationClientOption.GeoLanguage.values()[(int) optionMap.get("geoLanguage")]); 113 | } 114 | 115 | if (optionMap.containsKey("onceLocation")) { 116 | locationOption.setOnceLocation((boolean) optionMap.get("onceLocation")); 117 | } 118 | 119 | if (null != locationClient) { 120 | locationClient.setLocationOption(locationOption); 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /android/src/main/java/com/amap/location/amaplocationflutterplugin/AmapLocationFlutterPlugin.java: -------------------------------------------------------------------------------- 1 | package com.amap.location.amaplocationflutterplugin; 2 | 3 | import android.content.Context; 4 | import android.text.TextUtils; 5 | 6 | import com.amap.api.location.AMapLocationClient; 7 | 8 | import java.util.Map; 9 | import java.util.concurrent.ConcurrentHashMap; 10 | 11 | import io.flutter.embedding.engine.plugins.FlutterPlugin; 12 | import io.flutter.plugin.common.EventChannel; 13 | import io.flutter.plugin.common.MethodCall; 14 | import io.flutter.plugin.common.MethodChannel; 15 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler; 16 | import io.flutter.plugin.common.MethodChannel.Result; 17 | 18 | /** 19 | * 高德地图定位sdkFlutterPlugin 20 | */ 21 | public class AmapLocationFlutterPlugin implements MethodCallHandler, 22 | EventChannel.StreamHandler, 23 | FlutterPlugin { 24 | 25 | private static final String CHANNEL_METHOD_LOCATION = "amap_location_flutter_plugin"; 26 | private static final String CHANNEL_STREAM_LOCATION = "amap_location_flutter_plugin_stream"; 27 | 28 | private Context mContext = null; 29 | 30 | public static EventChannel.EventSink mEventSink = null; 31 | 32 | 33 | private Map locationClientMap = new ConcurrentHashMap(8); 34 | 35 | @Override 36 | public void onMethodCall(MethodCall call, Result result) { 37 | String callMethod = call.method; 38 | switch (call.method) { 39 | case "setApiKey": 40 | setApiKey((Map) call.arguments); 41 | break; 42 | case "setLocationOption": 43 | setLocationOption((Map) call.arguments); 44 | break; 45 | case "startLocation": 46 | startLocation((Map) call.arguments); 47 | break; 48 | case "stopLocation": 49 | stopLocation((Map) call.arguments); 50 | break; 51 | case "destroy": 52 | destroy((Map) call.arguments); 53 | break; 54 | default: 55 | result.notImplemented(); 56 | break; 57 | 58 | } 59 | } 60 | 61 | @Override 62 | public void onListen(Object o, EventChannel.EventSink eventSink) { 63 | mEventSink = eventSink; 64 | } 65 | 66 | @Override 67 | public void onCancel(Object o) { 68 | for (Map.Entry entry : locationClientMap.entrySet()) { 69 | entry.getValue().stopLocation(); 70 | } 71 | } 72 | 73 | /** 74 | * 开始定位 75 | */ 76 | private void startLocation(Map argsMap) { 77 | AMapLocationClientImpl locationClientImp = getLocationClientImp(argsMap); 78 | if (null != locationClientImp) { 79 | locationClientImp.startLocation(); 80 | } 81 | } 82 | 83 | 84 | /** 85 | * 停止定位 86 | */ 87 | private void stopLocation(Map argsMap) { 88 | AMapLocationClientImpl locationClientImp = getLocationClientImp(argsMap); 89 | if (null != locationClientImp) { 90 | locationClientImp.stopLocation(); 91 | } 92 | } 93 | 94 | /** 95 | * 销毁 96 | * 97 | * @param argsMap 98 | */ 99 | private void destroy(Map argsMap) { 100 | AMapLocationClientImpl locationClientImp = getLocationClientImp(argsMap); 101 | if (null != locationClientImp) { 102 | locationClientImp.destroy(); 103 | 104 | locationClientMap.remove(getPluginKeyFromArgs(argsMap)); 105 | } 106 | } 107 | 108 | /** 109 | * 设置apikey 110 | * 111 | * @param apiKeyMap 112 | */ 113 | private void setApiKey(Map apiKeyMap) { 114 | if (null != apiKeyMap) { 115 | if (apiKeyMap.containsKey("android") 116 | && !TextUtils.isEmpty((String) apiKeyMap.get("android"))) { 117 | AMapLocationClient.setApiKey((String) apiKeyMap.get("android")); 118 | } 119 | } 120 | } 121 | 122 | /** 123 | * 设置定位参数 124 | * 125 | * @param argsMap 126 | */ 127 | private void setLocationOption(Map argsMap) { 128 | AMapLocationClientImpl locationClientImp = getLocationClientImp(argsMap); 129 | if (null != locationClientImp) { 130 | locationClientImp.setLocationOption(argsMap); 131 | } 132 | } 133 | 134 | 135 | @Override 136 | public void onAttachedToEngine(FlutterPluginBinding binding) { 137 | if (null == mContext) { 138 | mContext = binding.getApplicationContext(); 139 | 140 | /** 141 | * 方法调用通道 142 | */ 143 | final MethodChannel channel = new MethodChannel(binding.getBinaryMessenger(), CHANNEL_METHOD_LOCATION); 144 | channel.setMethodCallHandler(this); 145 | 146 | /** 147 | * 回调监听通道 148 | */ 149 | final EventChannel eventChannel = new EventChannel(binding.getBinaryMessenger(), CHANNEL_STREAM_LOCATION); 150 | eventChannel.setStreamHandler(this); 151 | } 152 | 153 | } 154 | 155 | @Override 156 | public void onDetachedFromEngine(FlutterPluginBinding binding) { 157 | for (Map.Entry entry : locationClientMap.entrySet()) { 158 | entry.getValue().destroy(); 159 | } 160 | } 161 | 162 | private AMapLocationClientImpl getLocationClientImp(Map argsMap) { 163 | if (null == locationClientMap) { 164 | locationClientMap = new ConcurrentHashMap(8); 165 | } 166 | 167 | String pluginKey = getPluginKeyFromArgs(argsMap); 168 | if (TextUtils.isEmpty(pluginKey)) { 169 | return null; 170 | } 171 | 172 | if (!locationClientMap.containsKey(pluginKey)) { 173 | AMapLocationClientImpl locationClientImp = new AMapLocationClientImpl(mContext, pluginKey, mEventSink); 174 | locationClientMap.put(pluginKey, locationClientImp); 175 | } 176 | return locationClientMap.get(pluginKey); 177 | } 178 | 179 | private String getPluginKeyFromArgs(Map argsMap) { 180 | String pluginKey = null; 181 | try { 182 | if (null != argsMap) { 183 | pluginKey = (String) argsMap.get("pluginKey"); 184 | } 185 | } catch (Throwable e) { 186 | e.printStackTrace(); 187 | } 188 | return pluginKey; 189 | } 190 | 191 | 192 | } 193 | -------------------------------------------------------------------------------- /android/src/main/java/com/amap/location/amaplocationflutterplugin/Utils.java: -------------------------------------------------------------------------------- 1 | package com.amap.location.amaplocationflutterplugin; 2 | 3 | import android.text.TextUtils; 4 | 5 | import com.amap.api.location.AMapLocation; 6 | 7 | import java.text.SimpleDateFormat; 8 | import java.util.LinkedHashMap; 9 | import java.util.Locale; 10 | import java.util.Map; 11 | 12 | /** 13 | * @author whm 14 | * @date 2020-04-17 17:33 15 | * @mail hongming.whm@alibaba-inc.com 16 | * @since 17 | */ 18 | public class Utils { 19 | 20 | 21 | public static Map buildLocationResultMap(AMapLocation location) { 22 | Map result = new LinkedHashMap(); 23 | result.put("callbackTime", formatUTC(System.currentTimeMillis(), null)); 24 | if (null != location) { 25 | if (location.getErrorCode() == AMapLocation.LOCATION_SUCCESS) { 26 | result.put("locationTime", formatUTC(location.getTime(), null)); 27 | result.put("locationType", location.getLocationType()); 28 | result.put("latitude", location.getLatitude()); 29 | result.put("longitude", location.getLongitude()); 30 | result.put("accuracy", location.getAccuracy()); 31 | result.put("altitude", location.getAltitude()); 32 | result.put("bearing", location.getBearing()); 33 | result.put("speed", location.getSpeed()); 34 | result.put("country", location.getCountry()); 35 | result.put("province", location.getProvince()); 36 | result.put("city", location.getCity()); 37 | result.put("district", location.getDistrict()); 38 | result.put("street", location.getStreet()); 39 | result.put("streetNumber", location.getStreetNum()); 40 | result.put("cityCode", location.getCityCode()); 41 | result.put("adCode", location.getAdCode()); 42 | result.put("address", location.getAddress()); 43 | result.put("description", location.getDescription()); 44 | } else { 45 | result.put("errorCode", location.getErrorCode()); 46 | result.put("errorInfo", location.getErrorInfo() + "#" + location.getLocationDetail()); 47 | } 48 | } else { 49 | result.put("errorCode", -1); 50 | result.put("errorInfo", "location is null"); 51 | } 52 | return result; 53 | } 54 | 55 | /** 56 | * 格式化时间 57 | * 58 | * @param time 59 | * @param strPattern 60 | * @return 61 | */ 62 | public static String formatUTC(long time, String strPattern) { 63 | if (TextUtils.isEmpty(strPattern)) { 64 | strPattern = "yyyy-MM-dd HH:mm:ss"; 65 | } 66 | SimpleDateFormat sdf = null; 67 | try { 68 | sdf = new SimpleDateFormat(strPattern, Locale.CHINA); 69 | sdf.applyPattern(strPattern); 70 | } catch (Throwable e) { 71 | } 72 | return sdf == null ? "NULL" : sdf.format(time); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.lock 4 | *.log 5 | *.pyc 6 | *.swp 7 | .DS_Store 8 | .atom/ 9 | .buildlog/ 10 | .history 11 | .svn/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # Visual Studio Code related 20 | .vscode/ 21 | 22 | # Flutter/Dart/Pub related 23 | **/doc/api/ 24 | .dart_tool/ 25 | .flutter-plugins 26 | .packages 27 | .pub-cache/ 28 | .pub/ 29 | build/ 30 | 31 | # Android related 32 | **/android/**/gradle-wrapper.jar 33 | **/android/.gradle 34 | **/android/captures/ 35 | **/android/gradlew 36 | **/android/gradlew.bat 37 | **/android/local.properties 38 | **/android/**/GeneratedPluginRegistrant.java 39 | 40 | # iOS/XCode related 41 | **/ios/**/*.mode1v3 42 | **/ios/**/*.mode2v3 43 | **/ios/**/*.moved-aside 44 | **/ios/**/*.pbxuser 45 | **/ios/**/*.perspectivev3 46 | **/ios/**/*sync/ 47 | **/ios/**/.sconsign.dblite 48 | **/ios/**/.tags* 49 | **/ios/**/.vagrant/ 50 | **/ios/**/DerivedData/ 51 | **/ios/**/Icon? 52 | **/ios/**/Pods/ 53 | **/ios/**/.symlinks/ 54 | **/ios/**/profile 55 | **/ios/**/xcuserdata 56 | **/ios/.generated/ 57 | **/ios/Flutter/App.framework 58 | **/ios/Flutter/Flutter.framework 59 | **/ios/Flutter/Generated.xcconfig 60 | **/ios/Flutter/app.flx 61 | **/ios/Flutter/app.zip 62 | **/ios/Flutter/flutter_assets/ 63 | **/ios/ServiceDefinitions.json 64 | **/ios/Runner/GeneratedPluginRegistrant.* 65 | 66 | # Exceptions to above rules. 67 | !**/ios/**/default.mode1v3 68 | !**/ios/**/default.mode2v3 69 | !**/ios/**/default.pbxuser 70 | !**/ios/**/default.perspectivev3 71 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 72 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: f37c235c32fc15babe6dc7b7bc2ee4387e5ecf92 8 | channel: beta 9 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # amap_location_flutter_plugin_example 2 | 3 | Demonstrates how to use the amap_location_flutter_plugin plugin. 4 | 5 | ## Getting Started 6 | 7 | For help getting started with Flutter, view our online 8 | [documentation](https://flutter.io/). 9 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 26 | 27 | android { 28 | compileSdkVersion 28 29 | 30 | lintOptions { 31 | disable 'InvalidPackage' 32 | } 33 | 34 | defaultConfig { 35 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 36 | applicationId "com.amap.location.amaplocationflutterpluginexample" 37 | minSdkVersion 16 38 | targetSdkVersion 28 39 | versionCode flutterVersionCode.toInteger() 40 | versionName flutterVersionName 41 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 42 | } 43 | 44 | signingConfigs { 45 | debug { 46 | //keystore中key的别名 47 | keyAlias 'androiddebugkey' 48 | //keystore中key的密码 49 | keyPassword 'android' 50 | //keystore的文件路径,可以是绝对路径也可以是相对路径 51 | storeFile file('../../debug.keystore') 52 | //keystore的密码 53 | storePassword 'android' 54 | } 55 | } 56 | 57 | buildTypes { 58 | release { 59 | // TODO: Add your own signing config for the release build. 60 | // Signing with the debug keys for now, so `flutter run --release` works. 61 | signingConfig signingConfigs.debug 62 | } 63 | } 64 | } 65 | 66 | flutter { 67 | source '../..' 68 | } 69 | 70 | dependencies { 71 | testImplementation 'junit:junit:4.12' 72 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 73 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 74 | } 75 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 22 | 25 | 26 | 27 | 34 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/amap/location/amaplocationflutterpluginexample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.amap.location.amaplocationflutterpluginexample; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import io.flutter.embedding.engine.FlutterEngine; 6 | import io.flutter.plugins.GeneratedPluginRegistrant; 7 | import io.flutter.embedding.android.FlutterActivity; 8 | 9 | public class MainActivity extends FlutterActivity { 10 | @Override 11 | public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { 12 | GeneratedPluginRegistrant.registerWith(flutterEngine); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.5.1' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | google() 15 | jcenter() 16 | } 17 | } 18 | 19 | rootProject.buildDir = '../build' 20 | subprojects { 21 | project.buildDir = "${rootProject.buildDir}/${project.name}" 22 | } 23 | subprojects { 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /example/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/debug.keystore -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Flutter.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: This podspec is NOT to be published. It is only used as a local source! 3 | # 4 | 5 | Pod::Spec.new do |s| 6 | s.name = 'Flutter' 7 | s.version = '1.0.0' 8 | s.summary = 'High-performance, high-fidelity mobile apps.' 9 | s.description = <<-DESC 10 | Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS. 11 | DESC 12 | s.homepage = 'https://flutter.io' 13 | s.license = { :type => 'MIT' } 14 | s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } 15 | s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s } 16 | s.ios.deployment_target = '8.0' 17 | s.vendored_frameworks = 'Flutter.framework' 18 | end 19 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 32 | end 33 | 34 | post_install do |installer| 35 | installer.pods_project.targets.each do |target| 36 | flutter_additional_ios_build_settings(target) 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 50BC6E1A2DF7D627C42AAB59 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A97C8EAE44152371738568A /* libPods-Runner.a */; }; 13 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; 14 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 15 | 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; 16 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 17 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 18 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXCopyFilesBuildPhase section */ 22 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 23 | isa = PBXCopyFilesBuildPhase; 24 | buildActionMask = 2147483647; 25 | dstPath = ""; 26 | dstSubfolderSpec = 10; 27 | files = ( 28 | ); 29 | name = "Embed Frameworks"; 30 | runOnlyForDeploymentPostprocessing = 0; 31 | }; 32 | /* End PBXCopyFilesBuildPhase section */ 33 | 34 | /* Begin PBXFileReference section */ 35 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 36 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 37 | 2F5441A35B2B571CA4451B23 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 38 | 32D264EEAFD8742AA43805F4 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 39 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 40 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 41 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 42 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 43 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 44 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 45 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 47 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 48 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 49 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 50 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | 9A97C8EAE44152371738568A /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | /* End PBXFileReference section */ 53 | 54 | /* Begin PBXFrameworksBuildPhase section */ 55 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | 50BC6E1A2DF7D627C42AAB59 /* libPods-Runner.a in Frameworks */, 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | /* End PBXFrameworksBuildPhase section */ 64 | 65 | /* Begin PBXGroup section */ 66 | 4ED1D6396B38216086C3A7CC /* Pods */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 32D264EEAFD8742AA43805F4 /* Pods-Runner.debug.xcconfig */, 70 | 2F5441A35B2B571CA4451B23 /* Pods-Runner.release.xcconfig */, 71 | ); 72 | name = Pods; 73 | sourceTree = ""; 74 | }; 75 | 9740EEB11CF90186004384FC /* Flutter */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 79 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 80 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 81 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 82 | ); 83 | name = Flutter; 84 | sourceTree = ""; 85 | }; 86 | 97C146E51CF9000F007C117D = { 87 | isa = PBXGroup; 88 | children = ( 89 | 9740EEB11CF90186004384FC /* Flutter */, 90 | 97C146F01CF9000F007C117D /* Runner */, 91 | 97C146EF1CF9000F007C117D /* Products */, 92 | 4ED1D6396B38216086C3A7CC /* Pods */, 93 | CB86994C16566D45BFB79656 /* Frameworks */, 94 | ); 95 | sourceTree = ""; 96 | }; 97 | 97C146EF1CF9000F007C117D /* Products */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 97C146EE1CF9000F007C117D /* Runner.app */, 101 | ); 102 | name = Products; 103 | sourceTree = ""; 104 | }; 105 | 97C146F01CF9000F007C117D /* Runner */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, 109 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, 110 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 111 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 112 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 113 | 97C147021CF9000F007C117D /* Info.plist */, 114 | 97C146F11CF9000F007C117D /* Supporting Files */, 115 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 116 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 117 | ); 118 | path = Runner; 119 | sourceTree = ""; 120 | }; 121 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 97C146F21CF9000F007C117D /* main.m */, 125 | ); 126 | name = "Supporting Files"; 127 | sourceTree = ""; 128 | }; 129 | CB86994C16566D45BFB79656 /* Frameworks */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | 9A97C8EAE44152371738568A /* libPods-Runner.a */, 133 | ); 134 | name = Frameworks; 135 | sourceTree = ""; 136 | }; 137 | /* End PBXGroup section */ 138 | 139 | /* Begin PBXNativeTarget section */ 140 | 97C146ED1CF9000F007C117D /* Runner */ = { 141 | isa = PBXNativeTarget; 142 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 143 | buildPhases = ( 144 | FE3F7D89B821535EC0BB219A /* [CP] Check Pods Manifest.lock */, 145 | 9740EEB61CF901F6004384FC /* Run Script */, 146 | 97C146EA1CF9000F007C117D /* Sources */, 147 | 97C146EB1CF9000F007C117D /* Frameworks */, 148 | 97C146EC1CF9000F007C117D /* Resources */, 149 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 150 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 151 | CF049D2FC952BA3D554052E9 /* [CP] Embed Pods Frameworks */, 152 | ); 153 | buildRules = ( 154 | ); 155 | dependencies = ( 156 | ); 157 | name = Runner; 158 | productName = Runner; 159 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 160 | productType = "com.apple.product-type.application"; 161 | }; 162 | /* End PBXNativeTarget section */ 163 | 164 | /* Begin PBXProject section */ 165 | 97C146E61CF9000F007C117D /* Project object */ = { 166 | isa = PBXProject; 167 | attributes = { 168 | LastUpgradeCheck = 0910; 169 | ORGANIZATIONNAME = "The Chromium Authors"; 170 | TargetAttributes = { 171 | 97C146ED1CF9000F007C117D = { 172 | CreatedOnToolsVersion = 7.3.1; 173 | DevelopmentTeam = YMJ372W38W; 174 | ProvisioningStyle = Manual; 175 | SystemCapabilities = { 176 | com.apple.BackgroundModes = { 177 | enabled = 1; 178 | }; 179 | }; 180 | }; 181 | }; 182 | }; 183 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 184 | compatibilityVersion = "Xcode 3.2"; 185 | developmentRegion = English; 186 | hasScannedForEncodings = 0; 187 | knownRegions = ( 188 | English, 189 | en, 190 | Base, 191 | ); 192 | mainGroup = 97C146E51CF9000F007C117D; 193 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 194 | projectDirPath = ""; 195 | projectRoot = ""; 196 | targets = ( 197 | 97C146ED1CF9000F007C117D /* Runner */, 198 | ); 199 | }; 200 | /* End PBXProject section */ 201 | 202 | /* Begin PBXResourcesBuildPhase section */ 203 | 97C146EC1CF9000F007C117D /* Resources */ = { 204 | isa = PBXResourcesBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 208 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 209 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 210 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 211 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 212 | ); 213 | runOnlyForDeploymentPostprocessing = 0; 214 | }; 215 | /* End PBXResourcesBuildPhase section */ 216 | 217 | /* Begin PBXShellScriptBuildPhase section */ 218 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 219 | isa = PBXShellScriptBuildPhase; 220 | buildActionMask = 2147483647; 221 | files = ( 222 | ); 223 | inputPaths = ( 224 | ); 225 | name = "Thin Binary"; 226 | outputPaths = ( 227 | ); 228 | runOnlyForDeploymentPostprocessing = 0; 229 | shellPath = /bin/sh; 230 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 231 | }; 232 | 9740EEB61CF901F6004384FC /* Run Script */ = { 233 | isa = PBXShellScriptBuildPhase; 234 | buildActionMask = 2147483647; 235 | files = ( 236 | ); 237 | inputPaths = ( 238 | ); 239 | name = "Run Script"; 240 | outputPaths = ( 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | shellPath = /bin/sh; 244 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 245 | }; 246 | CF049D2FC952BA3D554052E9 /* [CP] Embed Pods Frameworks */ = { 247 | isa = PBXShellScriptBuildPhase; 248 | buildActionMask = 2147483647; 249 | files = ( 250 | ); 251 | inputPaths = ( 252 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", 253 | "${PODS_ROOT}/../Flutter/Flutter.framework", 254 | ); 255 | name = "[CP] Embed Pods Frameworks"; 256 | outputPaths = ( 257 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", 258 | ); 259 | runOnlyForDeploymentPostprocessing = 0; 260 | shellPath = /bin/sh; 261 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 262 | showEnvVarsInLog = 0; 263 | }; 264 | FE3F7D89B821535EC0BB219A /* [CP] Check Pods Manifest.lock */ = { 265 | isa = PBXShellScriptBuildPhase; 266 | buildActionMask = 2147483647; 267 | files = ( 268 | ); 269 | inputFileListPaths = ( 270 | ); 271 | inputPaths = ( 272 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 273 | "${PODS_ROOT}/Manifest.lock", 274 | ); 275 | name = "[CP] Check Pods Manifest.lock"; 276 | outputFileListPaths = ( 277 | ); 278 | outputPaths = ( 279 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | shellPath = /bin/sh; 283 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 284 | showEnvVarsInLog = 0; 285 | }; 286 | /* End PBXShellScriptBuildPhase section */ 287 | 288 | /* Begin PBXSourcesBuildPhase section */ 289 | 97C146EA1CF9000F007C117D /* Sources */ = { 290 | isa = PBXSourcesBuildPhase; 291 | buildActionMask = 2147483647; 292 | files = ( 293 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, 294 | 97C146F31CF9000F007C117D /* main.m in Sources */, 295 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | /* End PBXSourcesBuildPhase section */ 300 | 301 | /* Begin PBXVariantGroup section */ 302 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 303 | isa = PBXVariantGroup; 304 | children = ( 305 | 97C146FB1CF9000F007C117D /* Base */, 306 | ); 307 | name = Main.storyboard; 308 | sourceTree = ""; 309 | }; 310 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 311 | isa = PBXVariantGroup; 312 | children = ( 313 | 97C147001CF9000F007C117D /* Base */, 314 | ); 315 | name = LaunchScreen.storyboard; 316 | sourceTree = ""; 317 | }; 318 | /* End PBXVariantGroup section */ 319 | 320 | /* Begin XCBuildConfiguration section */ 321 | 97C147031CF9000F007C117D /* Debug */ = { 322 | isa = XCBuildConfiguration; 323 | buildSettings = { 324 | ALWAYS_SEARCH_USER_PATHS = NO; 325 | CLANG_ANALYZER_NONNULL = YES; 326 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 327 | CLANG_CXX_LIBRARY = "libc++"; 328 | CLANG_ENABLE_MODULES = YES; 329 | CLANG_ENABLE_OBJC_ARC = YES; 330 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 331 | CLANG_WARN_BOOL_CONVERSION = YES; 332 | CLANG_WARN_COMMA = YES; 333 | CLANG_WARN_CONSTANT_CONVERSION = YES; 334 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 335 | CLANG_WARN_EMPTY_BODY = YES; 336 | CLANG_WARN_ENUM_CONVERSION = YES; 337 | CLANG_WARN_INFINITE_RECURSION = YES; 338 | CLANG_WARN_INT_CONVERSION = YES; 339 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 340 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 341 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 342 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 343 | CLANG_WARN_STRICT_PROTOTYPES = YES; 344 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 345 | CLANG_WARN_UNREACHABLE_CODE = YES; 346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 347 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 348 | COPY_PHASE_STRIP = NO; 349 | DEBUG_INFORMATION_FORMAT = dwarf; 350 | ENABLE_STRICT_OBJC_MSGSEND = YES; 351 | ENABLE_TESTABILITY = YES; 352 | GCC_C_LANGUAGE_STANDARD = gnu99; 353 | GCC_DYNAMIC_NO_PIC = NO; 354 | GCC_NO_COMMON_BLOCKS = YES; 355 | GCC_OPTIMIZATION_LEVEL = 0; 356 | GCC_PREPROCESSOR_DEFINITIONS = ( 357 | "DEBUG=1", 358 | "$(inherited)", 359 | ); 360 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 361 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 362 | GCC_WARN_UNDECLARED_SELECTOR = YES; 363 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 364 | GCC_WARN_UNUSED_FUNCTION = YES; 365 | GCC_WARN_UNUSED_VARIABLE = YES; 366 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 367 | MTL_ENABLE_DEBUG_INFO = YES; 368 | ONLY_ACTIVE_ARCH = YES; 369 | SDKROOT = iphoneos; 370 | TARGETED_DEVICE_FAMILY = "1,2"; 371 | }; 372 | name = Debug; 373 | }; 374 | 97C147041CF9000F007C117D /* Release */ = { 375 | isa = XCBuildConfiguration; 376 | buildSettings = { 377 | ALWAYS_SEARCH_USER_PATHS = NO; 378 | CLANG_ANALYZER_NONNULL = YES; 379 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 380 | CLANG_CXX_LIBRARY = "libc++"; 381 | CLANG_ENABLE_MODULES = YES; 382 | CLANG_ENABLE_OBJC_ARC = YES; 383 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 384 | CLANG_WARN_BOOL_CONVERSION = YES; 385 | CLANG_WARN_COMMA = YES; 386 | CLANG_WARN_CONSTANT_CONVERSION = YES; 387 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 388 | CLANG_WARN_EMPTY_BODY = YES; 389 | CLANG_WARN_ENUM_CONVERSION = YES; 390 | CLANG_WARN_INFINITE_RECURSION = YES; 391 | CLANG_WARN_INT_CONVERSION = YES; 392 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 393 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 394 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 395 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 396 | CLANG_WARN_STRICT_PROTOTYPES = YES; 397 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 398 | CLANG_WARN_UNREACHABLE_CODE = YES; 399 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 400 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 401 | COPY_PHASE_STRIP = NO; 402 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 403 | ENABLE_NS_ASSERTIONS = NO; 404 | ENABLE_STRICT_OBJC_MSGSEND = YES; 405 | GCC_C_LANGUAGE_STANDARD = gnu99; 406 | GCC_NO_COMMON_BLOCKS = YES; 407 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 408 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 409 | GCC_WARN_UNDECLARED_SELECTOR = YES; 410 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 411 | GCC_WARN_UNUSED_FUNCTION = YES; 412 | GCC_WARN_UNUSED_VARIABLE = YES; 413 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 414 | MTL_ENABLE_DEBUG_INFO = NO; 415 | SDKROOT = iphoneos; 416 | TARGETED_DEVICE_FAMILY = "1,2"; 417 | VALIDATE_PRODUCT = YES; 418 | }; 419 | name = Release; 420 | }; 421 | 97C147061CF9000F007C117D /* Debug */ = { 422 | isa = XCBuildConfiguration; 423 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 424 | buildSettings = { 425 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 426 | CODE_SIGN_STYLE = Manual; 427 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 428 | DEVELOPMENT_TEAM = YMJ372W38W; 429 | ENABLE_BITCODE = NO; 430 | FRAMEWORK_SEARCH_PATHS = ( 431 | "$(inherited)", 432 | "$(PROJECT_DIR)/Flutter", 433 | ); 434 | INFOPLIST_FILE = Runner/Info.plist; 435 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 436 | LIBRARY_SEARCH_PATHS = ( 437 | "$(inherited)", 438 | "$(PROJECT_DIR)/Flutter", 439 | ); 440 | PRODUCT_BUNDLE_IDENTIFIER = com.amap.location.amaplocationflutterpluginexample; 441 | PRODUCT_NAME = "$(TARGET_NAME)"; 442 | PROVISIONING_PROFILE_SPECIFIER = OpenPlatform_Dev; 443 | VERSIONING_SYSTEM = "apple-generic"; 444 | }; 445 | name = Debug; 446 | }; 447 | 97C147071CF9000F007C117D /* Release */ = { 448 | isa = XCBuildConfiguration; 449 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 450 | buildSettings = { 451 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 452 | CODE_SIGN_STYLE = Manual; 453 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 454 | DEVELOPMENT_TEAM = YMJ372W38W; 455 | ENABLE_BITCODE = NO; 456 | FRAMEWORK_SEARCH_PATHS = ( 457 | "$(inherited)", 458 | "$(PROJECT_DIR)/Flutter", 459 | ); 460 | INFOPLIST_FILE = Runner/Info.plist; 461 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 462 | LIBRARY_SEARCH_PATHS = ( 463 | "$(inherited)", 464 | "$(PROJECT_DIR)/Flutter", 465 | ); 466 | PRODUCT_BUNDLE_IDENTIFIER = com.amap.location.amaplocationflutterpluginexample; 467 | PRODUCT_NAME = "$(TARGET_NAME)"; 468 | PROVISIONING_PROFILE_SPECIFIER = OpenPlatform_Dev; 469 | VERSIONING_SYSTEM = "apple-generic"; 470 | }; 471 | name = Release; 472 | }; 473 | /* End XCBuildConfiguration section */ 474 | 475 | /* Begin XCConfigurationList section */ 476 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 477 | isa = XCConfigurationList; 478 | buildConfigurations = ( 479 | 97C147031CF9000F007C117D /* Debug */, 480 | 97C147041CF9000F007C117D /* Release */, 481 | ); 482 | defaultConfigurationIsVisible = 0; 483 | defaultConfigurationName = Release; 484 | }; 485 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 486 | isa = XCConfigurationList; 487 | buildConfigurations = ( 488 | 97C147061CF9000F007C117D /* Debug */, 489 | 97C147071CF9000F007C117D /* Release */, 490 | ); 491 | defaultConfigurationIsVisible = 0; 492 | defaultConfigurationName = Release; 493 | }; 494 | /* End XCConfigurationList section */ 495 | }; 496 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 497 | } 498 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 56 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 75 | 77 | 83 | 84 | 85 | 86 | 88 | 89 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #include "AppDelegate.h" 2 | #include "GeneratedPluginRegistrant.h" 3 | 4 | @implementation AppDelegate 5 | 6 | - (BOOL)application:(UIApplication *)application 7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 8 | [GeneratedPluginRegistrant registerWithRegistry:self]; 9 | // Override point for customization after application launch. 10 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSLocationTemporaryUsageDescriptionDictionary 6 | 7 | AMapGeoFenceScene 8 | AMapLocationKit 地理围栏功能需要一次精确定位权限才可以正常使用 9 | AMapLocationScene 10 | AMapLocationKit 需要一次精确定位权限才可以正常使用 11 | 12 | CFBundleDevelopmentRegion 13 | en 14 | CFBundleExecutable 15 | $(EXECUTABLE_NAME) 16 | CFBundleIdentifier 17 | $(PRODUCT_BUNDLE_IDENTIFIER) 18 | CFBundleInfoDictionaryVersion 19 | 6.0 20 | CFBundleName 21 | amap_location_flutter_plugin_example 22 | CFBundlePackageType 23 | APPL 24 | CFBundleShortVersionString 25 | $(FLUTTER_BUILD_NAME) 26 | CFBundleSignature 27 | ???? 28 | CFBundleVersion 29 | $(FLUTTER_BUILD_NUMBER) 30 | LSRequiresIPhoneOS 31 | 32 | NSLocationAlwaysUsageDescription 33 | 权限说明,展示给用户的文案,需要您自行填写相关内容 34 | NSLocationWhenInUseUsageDescription 35 | aaaa 36 | UIBackgroundModes 37 | 38 | fetch 39 | location 40 | remote-notification 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIMainStoryboardFile 45 | Main 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UISupportedInterfaceOrientations~ipad 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationPortraitUpsideDown 56 | UIInterfaceOrientationLandscapeLeft 57 | UIInterfaceOrientationLandscapeRight 58 | 59 | UIViewControllerBasedStatusBarAppearance 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /example/ios/Runner/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char* argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:io'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:amap_location_flutter_plugin/amap_location_flutter_plugin.dart'; 5 | import 'package:amap_location_flutter_plugin/amap_location_option.dart'; 6 | import 'package:permission_handler/permission_handler.dart'; 7 | 8 | void main() { 9 | runApp(new MyApp()); 10 | } 11 | 12 | class MyApp extends StatefulWidget { 13 | @override 14 | _MyAppState createState() => new _MyAppState(); 15 | } 16 | 17 | class _MyAppState extends State { 18 | Map _locationResult; 19 | 20 | StreamSubscription> _locationListener; 21 | 22 | AmapLocationFlutterPlugin _locationPlugin = new AmapLocationFlutterPlugin(); 23 | 24 | @override 25 | void initState() { 26 | super.initState(); 27 | 28 | /// 动态申请定位权限 29 | requestPermission(); 30 | 31 | ///设置Android和iOS的apiKey
32 | ///key的申请请参考高德开放平台官网说明
33 | ///Android: https://lbs.amap.com/api/android-location-sdk/guide/create-project/get-key 34 | ///iOS: https://lbs.amap.com/api/ios-location-sdk/guide/create-project/get-key 35 | AmapLocationFlutterPlugin.setApiKey( 36 | "28bd43ed17d636692c8803e9e0d246b2", "dfb64c0463cb53927914364b5c09aba0"); 37 | 38 | ///iOS 获取native精度类型 39 | if (Platform.isIOS) { 40 | requestAccuracyAuthorization(); 41 | } 42 | 43 | ///注册定位结果监听 44 | _locationListener = _locationPlugin 45 | .onLocationChanged() 46 | .listen((Map result) { 47 | setState(() { 48 | _locationResult = result; 49 | }); 50 | }); 51 | } 52 | 53 | @override 54 | void dispose() { 55 | super.dispose(); 56 | 57 | ///移除定位监听 58 | if (null != _locationListener) { 59 | _locationListener.cancel(); 60 | } 61 | 62 | ///销毁定位 63 | if (null != _locationPlugin) { 64 | _locationPlugin.destroy(); 65 | } 66 | } 67 | 68 | ///设置定位参数 69 | void _setLocationOption() { 70 | if (null != _locationPlugin) { 71 | AMapLocationOption locationOption = new AMapLocationOption(); 72 | 73 | ///是否单次定位 74 | locationOption.onceLocation = false; 75 | 76 | ///是否需要返回逆地理信息 77 | locationOption.needAddress = true; 78 | 79 | ///逆地理信息的语言类型 80 | locationOption.geoLanguage = GeoLanguage.DEFAULT; 81 | 82 | locationOption.desiredLocationAccuracyAuthorizationMode = 83 | AMapLocationAccuracyAuthorizationMode.ReduceAccuracy; 84 | 85 | locationOption.fullAccuracyPurposeKey = "AMapLocationScene"; 86 | 87 | ///设置Android端连续定位的定位间隔 88 | locationOption.locationInterval = 2000; 89 | 90 | ///设置Android端的定位模式
91 | ///可选值:
92 | ///
  • [AMapLocationMode.Battery_Saving]
  • 93 | ///
  • [AMapLocationMode.Device_Sensors]
  • 94 | ///
  • [AMapLocationMode.Hight_Accuracy]
  • 95 | locationOption.locationMode = AMapLocationMode.Hight_Accuracy; 96 | 97 | ///设置iOS端的定位最小更新距离
    98 | locationOption.distanceFilter = -1; 99 | 100 | ///设置iOS端期望的定位精度 101 | /// 可选值:
    102 | ///
  • [DesiredAccuracy.Best] 最高精度
  • 103 | ///
  • [DesiredAccuracy.BestForNavigation] 适用于导航场景的高精度
  • 104 | ///
  • [DesiredAccuracy.NearestTenMeters] 10米
  • 105 | ///
  • [DesiredAccuracy.Kilometer] 1000米
  • 106 | ///
  • [DesiredAccuracy.ThreeKilometers] 3000米
  • 107 | locationOption.desiredAccuracy = DesiredAccuracy.Best; 108 | 109 | ///设置iOS端是否允许系统暂停定位 110 | locationOption.pausesLocationUpdatesAutomatically = false; 111 | 112 | ///将定位参数设置给定位插件 113 | _locationPlugin.setLocationOption(locationOption); 114 | } 115 | } 116 | 117 | ///开始定位 118 | void _startLocation() { 119 | if (null != _locationPlugin) { 120 | ///开始定位之前设置定位参数 121 | _setLocationOption(); 122 | _locationPlugin.startLocation(); 123 | } 124 | } 125 | 126 | ///停止定位 127 | void _stopLocation() { 128 | if (null != _locationPlugin) { 129 | _locationPlugin.stopLocation(); 130 | } 131 | } 132 | 133 | Container _createButtonContainer() { 134 | return new Container( 135 | alignment: Alignment.center, 136 | child: new Row( 137 | mainAxisSize: MainAxisSize.min, 138 | crossAxisAlignment: CrossAxisAlignment.center, 139 | children: [ 140 | new RaisedButton( 141 | onPressed: _startLocation, 142 | child: new Text('开始定位'), 143 | color: Colors.blue, 144 | textColor: Colors.white, 145 | ), 146 | new Container(width: 20.0), 147 | new RaisedButton( 148 | onPressed: _stopLocation, 149 | child: new Text('停止定位'), 150 | color: Colors.blue, 151 | textColor: Colors.white, 152 | ) 153 | ], 154 | )); 155 | } 156 | 157 | Widget _resultWidget(key, value) { 158 | return new Container( 159 | child: new Row( 160 | mainAxisSize: MainAxisSize.min, 161 | crossAxisAlignment: CrossAxisAlignment.center, 162 | children: [ 163 | new Container( 164 | alignment: Alignment.centerRight, 165 | width: 100.0, 166 | child: new Text('$key :'), 167 | ), 168 | new Container(width: 5.0), 169 | new Flexible(child: new Text('$value', softWrap: true)), 170 | ], 171 | ), 172 | ); 173 | } 174 | 175 | @override 176 | Widget build(BuildContext context) { 177 | List widgets = new List(); 178 | widgets.add(_createButtonContainer()); 179 | 180 | if (_locationResult != null) { 181 | _locationResult.forEach((key, value) { 182 | widgets.add(_resultWidget(key, value)); 183 | }); 184 | } 185 | 186 | return new MaterialApp( 187 | home: new Scaffold( 188 | appBar: new AppBar( 189 | title: new Text('AMap Location plugin example app'), 190 | ), 191 | body: new Column( 192 | crossAxisAlignment: CrossAxisAlignment.start, 193 | mainAxisSize: MainAxisSize.min, 194 | children: widgets, 195 | ), 196 | )); 197 | } 198 | 199 | ///获取iOS native的accuracyAuthorization类型 200 | void requestAccuracyAuthorization() async { 201 | AMapAccuracyAuthorization currentAccuracyAuthorization = 202 | await _locationPlugin.getSystemAccuracyAuthorization(); 203 | if (currentAccuracyAuthorization == 204 | AMapAccuracyAuthorization.AMapAccuracyAuthorizationFullAccuracy) { 205 | print("精确定位类型"); 206 | } else if (currentAccuracyAuthorization == 207 | AMapAccuracyAuthorization.AMapAccuracyAuthorizationReducedAccuracy) { 208 | print("模糊定位类型"); 209 | } else { 210 | print("未知定位类型"); 211 | } 212 | } 213 | 214 | /// 动态申请定位权限 215 | void requestPermission() async { 216 | // 申请权限 217 | bool hasLocationPermission = await requestLocationPermission(); 218 | if (hasLocationPermission) { 219 | print("定位权限申请通过"); 220 | } else { 221 | print("定位权限申请不通过"); 222 | } 223 | } 224 | 225 | /// 申请定位权限 226 | /// 授予定位权限返回true, 否则返回false 227 | Future requestLocationPermission() async { 228 | //获取当前的权限 229 | var status = await Permission.location.status; 230 | if (status == PermissionStatus.granted) { 231 | //已经授权 232 | return true; 233 | } else { 234 | //未授权则发起一次申请 235 | status = await Permission.location.request(); 236 | if (status == PermissionStatus.granted) { 237 | return true; 238 | } else { 239 | return false; 240 | } 241 | } 242 | } 243 | } 244 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: amap_location_flutter_plugin_example 2 | description: Demonstrates how to use the amap_location_flutter_plugin plugin. 3 | 4 | # The following defines the version and build number for your application. 5 | # A version number is three numbers separated by dots, like 1.2.43 6 | # followed by an optional build number separated by a +. 7 | # Both the version and the builder number may be overridden in flutter 8 | # build by specifying --build-name and --build-number, respectively. 9 | # Read more about versioning at semver.org. 10 | version: 1.0.0+1 11 | 12 | environment: 13 | sdk: ">=2.0.0<3.0.0" 14 | 15 | dependencies: 16 | flutter: 17 | sdk: flutter 18 | permission_handler: ^5.0.0 19 | 20 | # The following adds the Cupertino Icons font to your application. 21 | # Use with the CupertinoIcons class for iOS style icons. 22 | cupertino_icons: ^0.1.2 23 | 24 | dev_dependencies: 25 | flutter_test: 26 | sdk: flutter 27 | 28 | amap_location_flutter_plugin: 29 | path: ../ 30 | 31 | # For information on the generic Dart part of this file, see the 32 | # following page: https://www.dartlang.org/tools/pub/pubspec 33 | 34 | # The following section is specific to Flutter. 35 | flutter: 36 | 37 | # The following line ensures that the Material Icons font is 38 | # included with your application, so that you can use the icons in 39 | # the material Icons class. 40 | uses-material-design: true 41 | 42 | # To add assets to your application, add an assets section, like this: 43 | # assets: 44 | # - images/a_dot_burr.jpeg 45 | # - images/a_dot_ham.jpeg 46 | 47 | # An image asset can refer to one or more resolution-specific "variants", see 48 | # https://flutter.io/assets-and-images/#resolution-aware. 49 | 50 | # For details regarding adding assets from package dependencies, see 51 | # https://flutter.io/assets-and-images/#from-packages 52 | 53 | # To add custom fonts to your application, add a fonts section here, 54 | # in this "flutter" section. Each entry in this list should have a 55 | # "family" key with the font family name, and a "fonts" key with a 56 | # list giving the asset and other descriptors for the font. For 57 | # example: 58 | # fonts: 59 | # - family: Schyler 60 | # fonts: 61 | # - asset: fonts/Schyler-Regular.ttf 62 | # - asset: fonts/Schyler-Italic.ttf 63 | # style: italic 64 | # - family: Trajan Pro 65 | # fonts: 66 | # - asset: fonts/TrajanPro.ttf 67 | # - asset: fonts/TrajanPro_Bold.ttf 68 | # weight: 700 69 | # 70 | # For details regarding fonts from package dependencies, 71 | # see https://flutter.io/custom-fonts/#from-packages 72 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter 3 | // provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to 4 | // find child widgets in the widget tree, read text, and verify that the values of widget properties 5 | // are correct. 6 | 7 | import 'package:flutter/material.dart'; 8 | import 'package:flutter_test/flutter_test.dart'; 9 | 10 | import 'package:amap_location_flutter_plugin_example/main.dart'; 11 | 12 | void main() { 13 | testWidgets('Verify Platform version', (WidgetTester tester) async { 14 | // Build our app and trigger a frame. 15 | await tester.pumpWidget(new MyApp()); 16 | 17 | // Verify that platform version is retrieved. 18 | expect( 19 | find.byWidgetPredicate( 20 | (Widget widget) => 21 | widget is Text && widget.data.startsWith('Running on:'), 22 | ), 23 | findsOneWidget); 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | -------------------------------------------------------------------------------- /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/amap-location-flutter/55f473abec7bb360065099e9150f18a71d79d5a5/ios/Assets/.gitkeep -------------------------------------------------------------------------------- /ios/Classes/AmapFlutterStreamManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // AmapFlutterStreamManager.h 3 | // amap_location_flutter_plugin 4 | // 5 | // Created by ldj on 2018/10/30. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | @class AmapFlutterStreamHandler; 13 | @interface AmapFlutterStreamManager : NSObject 14 | + (instancetype)sharedInstance ; 15 | @property (nonatomic, strong) AmapFlutterStreamHandler* streamHandler; 16 | 17 | @end 18 | 19 | @interface AmapFlutterStreamHandler : NSObject 20 | @property (nonatomic, strong,nullable) FlutterEventSink eventSink; 21 | 22 | @end 23 | NS_ASSUME_NONNULL_END 24 | -------------------------------------------------------------------------------- /ios/Classes/AmapFlutterStreamManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // AmapFlutterStreamManager.m 3 | // amap_location_flutter_plugin 4 | // 5 | // Created by ldj on 2018/10/30. 6 | // 7 | 8 | #import "AmapFlutterStreamManager.h" 9 | 10 | @implementation AmapFlutterStreamManager 11 | 12 | + (instancetype)sharedInstance { 13 | static dispatch_once_t onceToken; 14 | static AmapFlutterStreamManager *manager = nil; 15 | dispatch_once(&onceToken, ^{ 16 | manager = [[AmapFlutterStreamManager alloc] init]; 17 | AmapFlutterStreamHandler * streamHandler = [[AmapFlutterStreamHandler alloc] init]; 18 | manager.streamHandler = streamHandler; 19 | }); 20 | 21 | return manager; 22 | } 23 | 24 | @end 25 | 26 | 27 | @implementation AmapFlutterStreamHandler 28 | 29 | - (FlutterError*)onListenWithArguments:(id)arguments eventSink:(FlutterEventSink)eventSink { 30 | self.eventSink = eventSink; 31 | return nil; 32 | } 33 | 34 | - (FlutterError*)onCancelWithArguments:(id)arguments { 35 | self.eventSink = nil; 36 | return nil; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /ios/Classes/AmapLocationFlutterPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface AmapLocationFlutterPlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /ios/Classes/AmapLocationFlutterPlugin.m: -------------------------------------------------------------------------------- 1 | #import "AmapLocationFlutterPlugin.h" 2 | #import 3 | #import 4 | #import "AmapFlutterStreamManager.h" 5 | 6 | @interface AMapFlutterLocationManager : AMapLocationManager 7 | 8 | @property (nonatomic, assign) BOOL onceLocation; 9 | @property (nonatomic, copy) FlutterResult flutterResult; 10 | @property (nonatomic, strong) NSString *pluginKey; 11 | @property (nonatomic, copy) NSString *fullAccuracyPurposeKey; 12 | 13 | @end 14 | 15 | @implementation AMapFlutterLocationManager 16 | 17 | - (instancetype)init { 18 | if ([super init] == self) { 19 | _onceLocation = false; 20 | _fullAccuracyPurposeKey = nil; 21 | } 22 | return self; 23 | } 24 | 25 | @end 26 | 27 | @interface AmapLocationFlutterPlugin() 28 | @property (nonatomic, strong) NSMutableDictionary *pluginsDict; 29 | 30 | @end 31 | 32 | @implementation AmapLocationFlutterPlugin 33 | 34 | + (void)registerWithRegistrar:(NSObject*)registrar { 35 | FlutterMethodChannel* channel = [FlutterMethodChannel 36 | methodChannelWithName:@"amap_location_flutter_plugin" 37 | binaryMessenger:[registrar messenger]]; 38 | AmapLocationFlutterPlugin* instance = [[AmapLocationFlutterPlugin alloc] init]; 39 | [registrar addMethodCallDelegate:instance channel:channel]; 40 | 41 | //AmapFlutterStreamHandler * streamHandler = [[AmapFlutterStreamHandler alloc] init]; 42 | FlutterEventChannel *eventChanel = [FlutterEventChannel eventChannelWithName:@"amap_location_flutter_plugin_stream" binaryMessenger:[registrar messenger]]; 43 | [eventChanel setStreamHandler:[[AmapFlutterStreamManager sharedInstance] streamHandler]]; 44 | 45 | } 46 | 47 | - (instancetype)init { 48 | if ([super init] == self) { 49 | _pluginsDict = [[NSMutableDictionary alloc] init]; 50 | } 51 | return self; 52 | } 53 | 54 | - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { 55 | if ([@"getPlatformVersion" isEqualToString:call.method]) { 56 | result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]); 57 | } else if ([@"startLocation" isEqualToString:call.method]){ 58 | [self startLocation:call result:result]; 59 | }else if ([@"stopLocation" isEqualToString:call.method]){ 60 | [self stopLocation:call]; 61 | result(@YES); 62 | }else if ([@"setLocationOption" isEqualToString:call.method]){ 63 | [self setLocationOption:call]; 64 | }else if ([@"destroy" isEqualToString:call.method]){ 65 | [self destroyLocation:call]; 66 | }else if ([@"setApiKey" isEqualToString:call.method]){ 67 | NSString *apiKey = call.arguments[@"ios"]; 68 | if (apiKey && [apiKey isKindOfClass:[NSString class]]) { 69 | [AMapServices sharedServices].apiKey = apiKey; 70 | result(@YES); 71 | }else { 72 | result(@NO); 73 | } 74 | }else if ([@"getSystemAccuracyAuthorization" isEqualToString:call.method]) { 75 | if (@available(iOS 14.0, *)) { 76 | [self getSystemAccuracyAuthorization:call result:result]; 77 | } 78 | }else { 79 | result(FlutterMethodNotImplemented); 80 | } 81 | } 82 | 83 | - (void)getSystemAccuracyAuthorization:(FlutterMethodCall*)call result:(FlutterResult)result { 84 | if (@available(iOS 14.0, *)) { 85 | AMapFlutterLocationManager *manager = [self locManagerWithCall:call]; 86 | CLAccuracyAuthorization curacyAuthorization = [manager currentAuthorization]; 87 | result(@(curacyAuthorization)); 88 | } 89 | } 90 | 91 | - (void)startLocation:(FlutterMethodCall*)call result:(FlutterResult)result 92 | { 93 | AMapFlutterLocationManager *manager = [self locManagerWithCall:call]; 94 | if (!manager) { 95 | return; 96 | } 97 | 98 | if (manager.onceLocation) { 99 | [manager requestLocationWithReGeocode:manager.locatingWithReGeocode completionBlock:^(CLLocation *location, AMapLocationReGeocode *regeocode, NSError *error) { 100 | [self handlePlugin:manager.pluginKey location:location reGeocode:regeocode error:error]; 101 | }]; 102 | } else { 103 | [manager setFlutterResult:result]; 104 | [manager startUpdatingLocation]; 105 | } 106 | } 107 | 108 | - (void)stopLocation:(FlutterMethodCall*)call 109 | { 110 | AMapFlutterLocationManager *manager = [self locManagerWithCall:call]; 111 | if (!manager) { 112 | return; 113 | } 114 | 115 | [manager setFlutterResult:nil]; 116 | [[self locManagerWithCall:call] stopUpdatingLocation]; 117 | } 118 | 119 | - (void)setLocationOption:(FlutterMethodCall*)call 120 | { 121 | AMapFlutterLocationManager *manager = [self locManagerWithCall:call]; 122 | if (!manager) { 123 | return; 124 | } 125 | 126 | NSNumber *needAddress = call.arguments[@"needAddress"]; 127 | if (needAddress) { 128 | [manager setLocatingWithReGeocode:[needAddress boolValue]]; 129 | } 130 | 131 | NSNumber *geoLanguage = call.arguments[@"geoLanguage"]; 132 | if (geoLanguage) { 133 | if ([geoLanguage integerValue] == 0) { 134 | [manager setReGeocodeLanguage:AMapLocationReGeocodeLanguageDefault]; 135 | } else if ([geoLanguage integerValue] == 1) { 136 | [manager setReGeocodeLanguage:AMapLocationReGeocodeLanguageChinse]; 137 | } else if ([geoLanguage integerValue] == 2) { 138 | [manager setReGeocodeLanguage:AMapLocationReGeocodeLanguageEnglish]; 139 | } 140 | } 141 | 142 | NSNumber *onceLocation = call.arguments[@"onceLocation"]; 143 | if (onceLocation) { 144 | manager.onceLocation = [onceLocation boolValue]; 145 | } 146 | 147 | NSNumber *pausesLocationUpdatesAutomatically = call.arguments[@"pausesLocationUpdatesAutomatically"]; 148 | if (pausesLocationUpdatesAutomatically) { 149 | [manager setPausesLocationUpdatesAutomatically:[pausesLocationUpdatesAutomatically boolValue]]; 150 | } 151 | 152 | NSNumber *desiredAccuracy = call.arguments[@"desiredAccuracy"]; 153 | if (desiredAccuracy) { 154 | 155 | if (desiredAccuracy.integerValue == 0) { 156 | [manager setDesiredAccuracy:kCLLocationAccuracyBest]; 157 | } else if (desiredAccuracy.integerValue == 1){ 158 | [manager setDesiredAccuracy:kCLLocationAccuracyBestForNavigation]; 159 | } else if (desiredAccuracy.integerValue == 2){ 160 | [manager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters]; 161 | } else if (desiredAccuracy.integerValue == 3){ 162 | [manager setDesiredAccuracy:kCLLocationAccuracyHundredMeters]; 163 | } else if (desiredAccuracy.integerValue == 4){ 164 | [manager setDesiredAccuracy:kCLLocationAccuracyKilometer]; 165 | } else if (desiredAccuracy.integerValue == 5){ 166 | [manager setDesiredAccuracy:kCLLocationAccuracyThreeKilometers]; 167 | } 168 | } 169 | 170 | NSNumber *distanceFilter = call.arguments[@"distanceFilter"]; 171 | if (distanceFilter) { 172 | if (distanceFilter.doubleValue == -1) { 173 | [manager setDistanceFilter:kCLDistanceFilterNone]; 174 | } else if (distanceFilter.doubleValue > 0) { 175 | [manager setDistanceFilter:distanceFilter.doubleValue]; 176 | } 177 | } 178 | 179 | if (@available(iOS 14.0, *)) { 180 | NSNumber *accuracyAuthorizationMode = call.arguments[@"locationAccuracyAuthorizationMode"]; 181 | if (accuracyAuthorizationMode) { 182 | if ([accuracyAuthorizationMode integerValue] == 0) { 183 | [manager setLocationAccuracyMode:AMapLocationFullAndReduceAccuracy]; 184 | } else if ([accuracyAuthorizationMode integerValue] == 1) { 185 | [manager setLocationAccuracyMode:AMapLocationFullAccuracy]; 186 | } else if ([accuracyAuthorizationMode integerValue] == 2) { 187 | [manager setLocationAccuracyMode:AMapLocationReduceAccuracy]; 188 | } 189 | } 190 | 191 | NSString *fullAccuracyPurposeKey = call.arguments[@"fullAccuracyPurposeKey"]; 192 | if (fullAccuracyPurposeKey) { 193 | manager.fullAccuracyPurposeKey = fullAccuracyPurposeKey; 194 | } 195 | } 196 | } 197 | 198 | - (void)destroyLocation:(FlutterMethodCall*)call 199 | { 200 | AMapFlutterLocationManager *manager = [self locManagerWithCall:call]; 201 | if (!manager) { 202 | return; 203 | } 204 | 205 | @synchronized (self) { 206 | if (manager.pluginKey) { 207 | [_pluginsDict removeObjectForKey:manager.pluginKey]; 208 | } 209 | } 210 | 211 | } 212 | 213 | - (void)handlePlugin:(NSString *)pluginKey location:(CLLocation *)location reGeocode:(AMapLocationReGeocode *)reGeocode error:(NSError *)error 214 | { 215 | if (!pluginKey || ![[AmapFlutterStreamManager sharedInstance] streamHandler].eventSink) { 216 | return; 217 | } 218 | NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:1]; 219 | [dic setObject:[self getFormatTime:[NSDate date]] forKey:@"callbackTime"]; 220 | [dic setObject:pluginKey forKey:@"pluginKey"]; 221 | 222 | if (location) { 223 | [dic setObject:[self getFormatTime:location.timestamp] forKey:@"locTime"]; 224 | [dic setValue:@1 forKey:@"locationType"]; 225 | [dic setObject:[NSString stringWithFormat:@"%f",location.coordinate.latitude] forKey:@"latitude"]; 226 | [dic setObject:[NSString stringWithFormat:@"%f",location.coordinate.longitude] forKey:@"longitude"]; 227 | [dic setValue:[NSNumber numberWithDouble:location.horizontalAccuracy] forKey:@"accuracy"]; 228 | [dic setValue:[NSNumber numberWithDouble:location.altitude] forKey:@"altitude"]; 229 | [dic setValue:[NSNumber numberWithDouble:location.course] forKey:@"bearing"]; 230 | [dic setValue:[NSNumber numberWithDouble:location.speed] forKey:@"speed"]; 231 | 232 | if (reGeocode) { 233 | if (reGeocode.country) { 234 | [dic setValue:reGeocode.country forKey:@"country"]; 235 | } 236 | 237 | if (reGeocode.province) { 238 | [dic setValue:reGeocode.province forKey:@"province"]; 239 | } 240 | 241 | if (reGeocode.city) { 242 | [dic setValue:reGeocode.city forKey:@"city"]; 243 | } 244 | 245 | if (reGeocode.district) { 246 | [dic setValue:reGeocode.district forKey:@"district"]; 247 | } 248 | 249 | if (reGeocode.street) { 250 | [dic setValue:reGeocode.street forKey:@"street"]; 251 | } 252 | 253 | if (reGeocode.number) { 254 | [dic setValue:reGeocode.number forKey:@"streetNumber"]; 255 | } 256 | 257 | if (reGeocode.citycode) { 258 | [dic setValue:reGeocode.citycode forKey:@"cityCode"]; 259 | } 260 | 261 | if (reGeocode.adcode) { 262 | [dic setValue:reGeocode.adcode forKey:@"adCode"]; 263 | } 264 | 265 | if (reGeocode.description) { 266 | [dic setValue:reGeocode.formattedAddress forKey:@"description"]; 267 | } 268 | 269 | if (reGeocode.formattedAddress.length) { 270 | [dic setObject:reGeocode.formattedAddress forKey:@"address"]; 271 | } 272 | } 273 | 274 | } else { 275 | [dic setObject:@"-1" forKey:@"errorCode"]; 276 | [dic setObject:@"location is null" forKey:@"errorInfo"]; 277 | 278 | } 279 | 280 | if (error) { 281 | [dic setObject:[NSNumber numberWithInteger:error.code] forKey:@"errorCode"]; 282 | [dic setObject:error.description forKey:@"errorInfo"]; 283 | } 284 | 285 | [[AmapFlutterStreamManager sharedInstance] streamHandler].eventSink(dic); 286 | //NSLog(@"x===%f,y===%f",location.coordinate.latitude,location.coordinate.longitude); 287 | } 288 | 289 | - (AMapFlutterLocationManager *)locManagerWithCall:(FlutterMethodCall*)call { 290 | 291 | if (!call || !call.arguments || !call.arguments[@"pluginKey"] || [call.arguments[@"pluginKey"] isKindOfClass:[NSString class]] == NO) { 292 | return nil; 293 | } 294 | 295 | NSString *pluginKey = call.arguments[@"pluginKey"]; 296 | 297 | AMapFlutterLocationManager *manager = nil; 298 | @synchronized (self) { 299 | manager = [_pluginsDict objectForKey:pluginKey]; 300 | } 301 | 302 | if (!manager) { 303 | manager = [[AMapFlutterLocationManager alloc] init]; 304 | manager.pluginKey = pluginKey; 305 | manager.locatingWithReGeocode = YES; 306 | manager.delegate = self; 307 | @synchronized (self) { 308 | [_pluginsDict setObject:manager forKey:pluginKey]; 309 | } 310 | } 311 | return manager; 312 | } 313 | 314 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 315 | 316 | /** 317 | * @brief 当plist配置NSLocationTemporaryUsageDescriptionDictionary且desiredAccuracyMode设置CLAccuracyAuthorizationFullAccuracy精确定位模式时,如果用户只授权模糊定位,会调用代理的此方法。此方法实现调用申请临时精确定位权限API即可: 318 | * [manager requestTemporaryFullAccuracyAuthorizationWithPurposeKey:@"PurposeKey" completion:^(NSError *error){ 319 | * if(completion){ 320 | * completion(error); 321 | * } 322 | * }]; (必须调用,不然无法正常获取临时精确定位权限) 323 | * @param manager 定位 AMapLocationManager 类。 324 | * @param locationManager 需要申请临时精确定位权限的locationManager。 325 | * @param completion 临时精确定位权限API回调结果,error: 直接返回系统error即可。 326 | * @since 2.6.7 327 | */ 328 | - (void)amapLocationManager:(AMapLocationManager *)manager doRequireTemporaryFullAccuracyAuth:(CLLocationManager*)locationManager completion:(void(^)(NSError *error))completion { 329 | if (@available(iOS 14.0, *)) { 330 | if ([manager isKindOfClass:[AMapFlutterLocationManager class]]) { 331 | AMapFlutterLocationManager *flutterLocationManager = (AMapFlutterLocationManager*)manager; 332 | if (flutterLocationManager.fullAccuracyPurposeKey && [flutterLocationManager.fullAccuracyPurposeKey length] > 0) { 333 | NSDictionary *locationTemporaryDictionary = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationTemporaryUsageDescriptionDictionary"]; 334 | BOOL hasLocationTemporaryKey = locationTemporaryDictionary != nil && locationTemporaryDictionary.count != 0; 335 | if (hasLocationTemporaryKey) { 336 | if ([locationTemporaryDictionary objectForKey:flutterLocationManager.fullAccuracyPurposeKey]) { 337 | [locationManager requestTemporaryFullAccuracyAuthorizationWithPurposeKey:flutterLocationManager.fullAccuracyPurposeKey completion:^(NSError * _Nullable error) { 338 | if (completion) { 339 | completion(error); 340 | } 341 | 342 | }]; 343 | } else { 344 | NSLog(@"[AMapLocationKit] 要在iOS 14及以上版本使用精确定位, 在amap_location_option.dart 中配置的fullAccuracyPurposeKey的key不包含在infoPlist中,请检查配置的key是否正确"); 345 | } 346 | } else { 347 | NSLog(@"[AMapLocationKit] 要在iOS 14及以上版本使用精确定位, 需要在Info.plist中添加NSLocationTemporaryUsageDescriptionDictionary字典,且自定义Key描述精确定位的使用场景。"); 348 | } 349 | 350 | } else { 351 | NSLog(@"[AMapLocationKit] 要在iOS 14及以上版本使用精确定位, 需要在amap_location_option.dart 中配置对应场景下fullAccuracyPurposeKey的key。注意:这个key要和infoPlist中的配置一样"); 352 | } 353 | } 354 | } 355 | } 356 | #endif 357 | 358 | /** 359 | * @brief 当plist配置NSLocationAlwaysUsageDescription或者NSLocationAlwaysAndWhenInUseUsageDescription,并且[CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined,会调用代理的此方法。 360 | 此方法实现调用申请后台权限API即可:[locationManager requestAlwaysAuthorization](必须调用,不然无法正常获取定位权限) 361 | * @param manager 定位 AMapLocationManager 类。 362 | * @param locationManager 需要申请后台定位权限的locationManager。 363 | * @since 2.6.2 364 | */ 365 | - (void)amapLocationManager:(AMapLocationManager *)manager doRequireLocationAuth:(CLLocationManager*)locationManager 366 | { 367 | [locationManager requestWhenInUseAuthorization]; 368 | } 369 | 370 | /** 371 | * @brief 当定位发生错误时,会调用代理的此方法。 372 | * @param manager 定位 AMapLocationManager 类。 373 | * @param error 返回的错误,参考 CLError 。 374 | */ 375 | - (void)amapLocationManager:(AMapLocationManager *)manager didFailWithError:(NSError *)error 376 | { 377 | [self handlePlugin:((AMapFlutterLocationManager *)manager).pluginKey location:nil reGeocode:nil error:error]; 378 | } 379 | 380 | 381 | /** 382 | * @brief 连续定位回调函数.注意:如果实现了本方法,则定位信息不会通过amapLocationManager:didUpdateLocation:方法回调。 383 | * @param manager 定位 AMapLocationManager 类。 384 | * @param location 定位结果。 385 | * @param reGeocode 逆地理信息。 386 | */ 387 | - (void)amapLocationManager:(AMapLocationManager *)manager didUpdateLocation:(CLLocation *)location reGeocode:(AMapLocationReGeocode *)reGeocode 388 | { 389 | [self handlePlugin:((AMapFlutterLocationManager *)manager).pluginKey location:location reGeocode:reGeocode error:nil]; 390 | } 391 | 392 | - (NSString *)getFormatTime:(NSDate*)date 393 | { 394 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 395 | [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"]; 396 | NSString *timeString = [formatter stringFromDate:date]; 397 | return timeString; 398 | } 399 | 400 | @end 401 | -------------------------------------------------------------------------------- /ios/amap_location_flutter_plugin.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 3 | # 4 | Pod::Spec.new do |s| 5 | s.name = 'amap_location_flutter_plugin' 6 | s.version = '0.0.1' 7 | s.summary = 'AMapLocation flutter plugin' 8 | s.description = <<-DESC 9 | AMapLocation flutter plugin 10 | DESC 11 | s.homepage = 'http://example.com' 12 | s.license = { :file => '../LICENSE' } 13 | s.author = { 'Your Company' => 'email@example.com' } 14 | s.source = { :path => '.' } 15 | s.source_files = 'Classes/**/*' 16 | s.public_header_files = 'Classes/**/*.h' 17 | s.dependency 'Flutter' 18 | 19 | s.static_framework = true 20 | s.ios.deployment_target = '8.0' 21 | s.dependency 'AMapLocation','~>2.6.7' 22 | end 23 | 24 | -------------------------------------------------------------------------------- /lib/amap_location_flutter_plugin.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:io'; 3 | import 'package:flutter/services.dart'; 4 | import 'amap_location_option.dart'; 5 | 6 | class AmapLocationFlutterPlugin { 7 | static const String _CHANNEL_METHOD_LOCATION = "amap_location_flutter_plugin"; 8 | static const String _CHANNEL_STREAM_LOCATION = 9 | "amap_location_flutter_plugin_stream"; 10 | 11 | static const MethodChannel _methodChannel = 12 | const MethodChannel(_CHANNEL_METHOD_LOCATION); 13 | 14 | static const EventChannel _eventChannel = 15 | const EventChannel(_CHANNEL_STREAM_LOCATION); 16 | 17 | static Stream> _onLocationChanged = _eventChannel 18 | .receiveBroadcastStream() 19 | .asBroadcastStream() 20 | .map>((element) => element.cast()); 21 | 22 | StreamController> _receiveStream; 23 | StreamSubscription> _subscription; 24 | String _pluginKey; 25 | 26 | /// 适配iOS 14定位新特性,只在iOS平台有效 27 | Future getSystemAccuracyAuthorization() async { 28 | int result = -1; 29 | if (Platform.isIOS) { 30 | result = await _methodChannel.invokeMethod( 31 | "getSystemAccuracyAuthorization", {'pluginKey': _pluginKey}); 32 | } 33 | if (result == 0) { 34 | return AMapAccuracyAuthorization.AMapAccuracyAuthorizationFullAccuracy; 35 | } else if (result == 1) { 36 | return AMapAccuracyAuthorization.AMapAccuracyAuthorizationReducedAccuracy; 37 | } 38 | return AMapAccuracyAuthorization.AMapAccuracyAuthorizationInvalid; 39 | } 40 | 41 | ///初始化 42 | AmapLocationFlutterPlugin() { 43 | _pluginKey = DateTime.now().millisecondsSinceEpoch.toString(); 44 | } 45 | 46 | ///开始定位 47 | void startLocation() { 48 | _methodChannel.invokeMethod('startLocation', {'pluginKey': _pluginKey}); 49 | return; 50 | } 51 | 52 | ///停止定位 53 | void stopLocation() { 54 | _methodChannel.invokeMethod('stopLocation', {'pluginKey': _pluginKey}); 55 | return; 56 | } 57 | 58 | ///设置Android和iOS的apikey,建议在weigdet初始化时设置
    59 | ///apiKey的申请请参考高德开放平台官网
    60 | ///Android端: https://lbs.amap.com/api/android-location-sdk/guide/create-project/get-key
    61 | ///iOS端: https://lbs.amap.com/api/ios-location-sdk/guide/create-project/get-key
    62 | ///[androidKey] Android平台的key
    63 | ///[iosKey] ios平台的key
    64 | static void setApiKey(String androidKey, String iosKey) { 65 | _methodChannel 66 | .invokeMethod('setApiKey', {'android': androidKey, 'ios': iosKey}); 67 | } 68 | 69 | /// 设置定位参数 70 | void setLocationOption(AMapLocationOption locationOption) { 71 | Map option = locationOption.getOptionsMap(); 72 | option['pluginKey'] = _pluginKey; 73 | _methodChannel.invokeMethod('setLocationOption', option); 74 | } 75 | 76 | ///销毁定位 77 | void destroy() { 78 | _methodChannel.invokeListMethod('destroy', {'pluginKey': _pluginKey}); 79 | if (_subscription != null) { 80 | _receiveStream.close(); 81 | _subscription.cancel(); 82 | _receiveStream = null; 83 | _subscription = null; 84 | } 85 | } 86 | 87 | ///定位结果回调 88 | Stream> onLocationChanged() { 89 | if (_receiveStream == null) { 90 | _receiveStream = StreamController(); 91 | _subscription = _onLocationChanged.listen((Map event) { 92 | if (event != null && event['pluginKey'] == _pluginKey) { 93 | Map newEvent = Map.of(event); 94 | newEvent.remove('pluginKey'); 95 | _receiveStream.add(newEvent); 96 | } 97 | }); 98 | } 99 | return _receiveStream.stream; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /lib/amap_location_option.dart: -------------------------------------------------------------------------------- 1 | 2 | /// 定位参数设置 3 | class AMapLocationOption { 4 | /// 是否需要地址信息,默认true 5 | bool needAddress = true; 6 | 7 | ///逆地理信息语言类型
    8 | ///默认[GeoLanguage.DEFAULT] 自动适配
    9 | ///可选值:
    10 | ///
  • [GeoLanguage.DEFAULT] 自动适配
  • 11 | ///
  • [GeoLanguage.EN] 英文
  • 12 | ///
  • [GeoLanguage.ZH] 中文
  • 13 | GeoLanguage geoLanguage; 14 | 15 | ///是否单次定位 16 | ///默认值:false 17 | bool onceLocation = false; 18 | 19 | ///Android端定位模式, 只在Android系统上有效
    20 | ///默认值:[AMapLocationMode.Hight_Accuracy]
    21 | ///可选值:
    22 | ///
  • [AMapLocationMode.Battery_Saving]
  • 23 | ///
  • [AMapLocationMode.Device_Sensors]
  • 24 | ///
  • [AMapLocationMode.Hight_Accuracy]
  • 25 | AMapLocationMode locationMode; 26 | 27 | ///Android端定位间隔
    28 | ///单位:毫秒
    29 | ///默认:2000毫秒
    30 | int locationInterval = 2000; 31 | 32 | ///iOS端是否允许系统暂停定位
    33 | ///默认:false 34 | bool pausesLocationUpdatesAutomatically = false; 35 | 36 | /// iOS端期望的定位精度, 只在iOS端有效
    37 | /// 默认值:最高精度
    38 | /// 可选值:
    39 | ///
  • [DesiredAccuracy.Best] 最高精度
  • 40 | ///
  • [DesiredAccuracy.BestForNavigation] 适用于导航场景的高精度
  • 41 | ///
  • [DesiredAccuracy.NearestTenMeters] 10米
  • 42 | ///
  • [DesiredAccuracy.Kilometer] 1000米
  • 43 | ///
  • [DesiredAccuracy.ThreeKilometers] 3000米
  • 44 | DesiredAccuracy desiredAccuracy = DesiredAccuracy.Best; 45 | 46 | /// iOS端定位最小更新距离
    47 | /// 单位:米
    48 | /// 默认值:-1,不做限制
    49 | double distanceFilter = -1; 50 | 51 | ///iOS 14中设置期望的定位精度权限 52 | AMapLocationAccuracyAuthorizationMode desiredLocationAccuracyAuthorizationMode = AMapLocationAccuracyAuthorizationMode.FullAccuracy; 53 | 54 | /// iOS 14中定位精度权限由模糊定位升级到精确定位时,需要用到的场景key fullAccuracyPurposeKey 这个key要和plist中的配置一样 55 | String fullAccuracyPurposeKey = ""; 56 | 57 | AMapLocationOption( 58 | { 59 | this.locationInterval = 2000, 60 | this.needAddress = true, 61 | this.locationMode = AMapLocationMode.Hight_Accuracy, 62 | this.geoLanguage = GeoLanguage.DEFAULT, 63 | this.onceLocation = false, 64 | this.pausesLocationUpdatesAutomatically = false, 65 | this.desiredAccuracy = DesiredAccuracy.Best, 66 | this.distanceFilter = -1, 67 | this.desiredLocationAccuracyAuthorizationMode = AMapLocationAccuracyAuthorizationMode.FullAccuracy}); 68 | 69 | ///获取设置的定位参数对应的Map 70 | Map getOptionsMap() { 71 | return { 72 | "locationInterval": this.locationInterval, 73 | "needAddress": needAddress, 74 | "locationMode": locationMode.index, 75 | "geoLanguage": geoLanguage.index, 76 | "onceLocation": onceLocation, 77 | "pausesLocationUpdatesAutomatically": pausesLocationUpdatesAutomatically, 78 | "desiredAccuracy": desiredAccuracy.index, 79 | 'distanceFilter': distanceFilter, 80 | "locationAccuracyAuthorizationMode": desiredLocationAccuracyAuthorizationMode.index, 81 | "fullAccuracyPurposeKey":fullAccuracyPurposeKey 82 | }; 83 | } 84 | } 85 | 86 | ///Android端定位模式 87 | enum AMapLocationMode { 88 | /// 低功耗模式 89 | Battery_Saving, 90 | 91 | /// 仅设备模式,不支持室内环境的定位 92 | Device_Sensors, 93 | 94 | /// 高精度模式 95 | Hight_Accuracy 96 | } 97 | 98 | ///逆地理信息语言 99 | enum GeoLanguage { 100 | /// 默认,自动适配 101 | DEFAULT, 102 | 103 | /// 汉语,无论在国内还是国外都返回英文 104 | ZH, 105 | 106 | /// 英语,无论在国内还是国外都返回中文 107 | EN 108 | } 109 | 110 | ///iOS中期望的定位精度 111 | enum DesiredAccuracy { 112 | ///最高精度 113 | Best, 114 | 115 | ///适用于导航场景的高精度 116 | BestForNavigation, 117 | 118 | ///10米 119 | NearestTenMeters, 120 | 121 | ///100米 122 | HundredMeters, 123 | 124 | ///1000米 125 | Kilometer, 126 | 127 | ///3000米 128 | ThreeKilometers, 129 | } 130 | 131 | ///iOS 14中期望的定位精度,只有在iOS 14的设备上才能生效 132 | enum AMapLocationAccuracyAuthorizationMode { 133 | ///精确和模糊定位 134 | FullAndReduceAccuracy, 135 | 136 | ///精确定位 137 | FullAccuracy, 138 | 139 | ///模糊定位 140 | ReduceAccuracy 141 | } 142 | 143 | ///iOS 14中系统的定位类型信息 144 | enum AMapAccuracyAuthorization { 145 | ///系统的精确定位类型 146 | AMapAccuracyAuthorizationFullAccuracy, 147 | 148 | ///系统的模糊定位类型 149 | AMapAccuracyAuthorizationReducedAccuracy, 150 | 151 | ///未知类型 152 | AMapAccuracyAuthorizationInvalid 153 | } -------------------------------------------------------------------------------- /lib/generated/i18n.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | // ignore_for_file: non_constant_identifier_names 7 | // ignore_for_file: camel_case_types 8 | // ignore_for_file: prefer_single_quotes 9 | 10 | //This file is automatically generated. DO NOT EDIT, all your changes would be lost. 11 | class S implements WidgetsLocalizations { 12 | const S(); 13 | 14 | static const GeneratedLocalizationsDelegate delegate = 15 | GeneratedLocalizationsDelegate(); 16 | 17 | static S of(BuildContext context) => Localizations.of(context, S); 18 | 19 | @override 20 | TextDirection get textDirection => TextDirection.ltr; 21 | } 22 | 23 | class en extends S { 24 | const en(); 25 | } 26 | 27 | class GeneratedLocalizationsDelegate extends LocalizationsDelegate { 28 | const GeneratedLocalizationsDelegate(); 29 | 30 | List get supportedLocales { 31 | return const [ 32 | Locale("en", ""), 33 | ]; 34 | } 35 | 36 | LocaleListResolutionCallback listResolution({Locale fallback}) { 37 | return (List locales, Iterable supported) { 38 | if (locales == null || locales.isEmpty) { 39 | return fallback ?? supported.first; 40 | } else { 41 | return _resolve(locales.first, fallback, supported); 42 | } 43 | }; 44 | } 45 | 46 | LocaleResolutionCallback resolution({Locale fallback}) { 47 | return (Locale locale, Iterable supported) { 48 | return _resolve(locale, fallback, supported); 49 | }; 50 | } 51 | 52 | Locale _resolve(Locale locale, Locale fallback, Iterable supported) { 53 | if (locale == null || !isSupported(locale)) { 54 | return fallback ?? supported.first; 55 | } 56 | 57 | final Locale languageLocale = Locale(locale.languageCode, ""); 58 | if (supported.contains(locale)) { 59 | return locale; 60 | } else if (supported.contains(languageLocale)) { 61 | return languageLocale; 62 | } else { 63 | final Locale fallbackLocale = fallback ?? supported.first; 64 | return fallbackLocale; 65 | } 66 | } 67 | 68 | @override 69 | Future load(Locale locale) { 70 | final String lang = getLang(locale); 71 | if (lang != null) { 72 | switch (lang) { 73 | case "en": 74 | return SynchronousFuture(const en()); 75 | default: 76 | // NO-OP. 77 | } 78 | } 79 | return SynchronousFuture(const S()); 80 | } 81 | 82 | @override 83 | bool isSupported(Locale locale) => 84 | locale != null && supportedLocales.contains(locale); 85 | 86 | @override 87 | bool shouldReload(GeneratedLocalizationsDelegate old) => false; 88 | } 89 | 90 | String getLang(Locale l) => l == null 91 | ? null 92 | : l.countryCode != null && l.countryCode.isEmpty 93 | ? l.languageCode 94 | : l.toString(); 95 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: amap_location_flutter_plugin 2 | description: AMapLocation flutter plugin 3 | version: 0.1.4 4 | homepage: https://lbs.amap.com/ 5 | repository: https://github.com/amap-demo/amap-location-flutter 6 | 7 | 8 | environment: 9 | sdk: ">=2.1.0 <3.0.0" 10 | flutter: ">=1.10.0" 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | 15 | 16 | # 并没有实际使用flutter_svg,仅是为了解决flutter 1.20.0 的兼容性问题;后续版本可以不依赖该库 17 | # dependency_overrides: 18 | # flutter_svg: 0.18.1 19 | 20 | # For information on the generic Dart part of this file, see the 21 | # following page: https://www.dartlang.org/tools/pub/pubspec 22 | 23 | # The following section is specific to Flutter. 24 | flutter: 25 | plugin: 26 | # androidPackage: com.amap.location.amaplocationflutterplugin 27 | # pluginClass: AmapLocationFlutterPlugin 28 | platforms: 29 | android: 30 | package: com.amap.location.amaplocationflutterplugin 31 | pluginClass: AmapLocationFlutterPlugin 32 | ios: 33 | pluginClass: AmapLocationFlutterPlugin 34 | 35 | 36 | # To add assets to your plugin package, add an assets section, like this: 37 | # assets: 38 | # - images/a_dot_burr.jpeg 39 | # - images/a_dot_ham.jpeg 40 | # 41 | # For details regarding assets in packages, see 42 | # https://flutter.io/assets-and-images/#from-packages 43 | # 44 | # An image asset can refer to one or more resolution-specific "variants", see 45 | # https://flutter.io/assets-and-images/#resolution-aware. 46 | 47 | # To add custom fonts to your plugin package, add a fonts section here, 48 | # in this "flutter" section. Each entry in this list should have a 49 | # "family" key with the font family name, and a "fonts" key with a 50 | # list giving the asset and other descriptors for the font. For 51 | # example: 52 | # fonts: 53 | # - family: Schyler 54 | # fonts: 55 | # - asset: fonts/Schyler-Regular.ttf 56 | # - asset: fonts/Schyler-Italic.ttf 57 | # style: italic 58 | # - family: Trajan Pro 59 | # fonts: 60 | # - asset: fonts/TrajanPro.ttf 61 | # - asset: fonts/TrajanPro_Bold.ttf 62 | # weight: 700 63 | # 64 | # For details regarding fonts in packages, see 65 | # https://flutter.io/custom-fonts/#from-packages 66 | -------------------------------------------------------------------------------- /res/values/strings_en.arb: -------------------------------------------------------------------------------- 1 | {} --------------------------------------------------------------------------------