├── .gitignore
├── .idea
├── codeStyles
│ └── Project.xml
├── libraries
│ ├── Dart_SDK.xml
│ ├── Flutter_Plugins.xml
│ └── Flutter_for_Android.xml
├── misc.xml
├── modules.xml
├── runConfigurations
│ └── example_lib_main_dart.xml
├── vcs.xml
└── workspace.xml
├── .metadata
├── CHANGELOG.md
├── LICENSE
├── README.md
├── amap_location.iml
├── android
├── .gitignore
├── build.gradle
├── gradle.properties
├── settings.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── jzoom
│ └── amaplocation
│ └── AmapLocationPlugin.java
├── example
├── .gitignore
├── .idea
│ ├── libraries
│ │ ├── Dart_SDK.xml
│ │ └── Flutter_for_Android.xml
│ ├── modules.xml
│ ├── runConfigurations
│ │ └── main_dart.xml
│ └── workspace.xml
├── .metadata
├── README.md
├── amap_location_example.iml
├── android
│ ├── app
│ │ ├── build.gradle
│ │ ├── flutter_amap_location_example.keystore
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── amap_location_example
│ │ │ │ │ └── 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
│ │ │ └── profile
│ │ │ └── AndroidManifest.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── ios
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ └── Release.xcconfig
│ ├── Podfile
│ ├── Podfile.lock
│ ├── Runner-Bridging-Header.h
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ └── WorkspaceSettings.xcsettings
│ ├── 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
│ └── bridge.swift
├── lib
│ └── main.dart
├── pubspec.lock
├── pubspec.yaml
└── test
│ └── widget_test.dart
├── ios
├── .gitignore
├── Assets
│ └── .gitkeep
├── Classes
│ ├── AmapLocationPlugin.h
│ └── AmapLocationPlugin.m
└── amap_location.podspec
├── lib
├── amap_location.dart
└── amap_location_option.dart
├── pubspec.lock
├── pubspec.yaml
└── test
└── amap_location_test.dart
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .dart_tool/
3 |
4 | .packages
5 | .pub/
6 |
7 | build/
8 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.idea/libraries/Dart_SDK.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/libraries/Flutter_Plugins.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/libraries/Flutter_for_Android.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/example_lib_main_dart.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 | 1554269310263
184 |
185 |
186 | 1554269310263
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
--------------------------------------------------------------------------------
/.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: 8661d8aecd626f7f57ccbcb735553edc05a2e713
8 | channel: stable
9 |
10 | project_type: plugin
11 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [0.2.0] - [2019-04-03]
2 | * 修复android新项目不能编译
3 | * 修复ios下偶然出现的空指针
4 |
5 | ## [0.1.2] - [2018-11-15]
6 | * 修正ios不能编译的问题,感谢群友@a396901990的PR
7 | * 修复ios偶然出现AOIName为nil导致程序崩溃的bug
8 |
9 | ## [0.1.1] - [2018-09-11]
10 | * 修正key的问题
11 |
12 | ## [0.0.7] - [2018-09-10]
13 | * 将权限内置到lib中
14 |
15 |
16 | ## [0.0.3] - [2018-09-10]
17 | * 修复一些版本适配问题
18 |
19 |
20 | ## [0.0.2] - [2018-05-15]
21 | * 更新README
22 |
23 |
24 | ## [0.0.1] - [2018-05-15]
25 | * ANDROID
26 | * IOS
27 | * 直接获取定位
28 | * 监听定位改变
29 | * TODO: Describe initial release.
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 JZoom
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | @@ -1,184 +1,14 @@
2 | # amap_location
3 |
4 |
5 |
6 |
7 |
8 |
9 | # flutter_amap_location
10 |
11 |
12 | 
13 |
14 | 
15 |
16 | 高德地图定位flutter组件。
17 |
18 | 目前实现直接获取定位和监听定位功能。
19 |
20 | 注意:随着flutter版本的提升, 本项目也会随之更新,
21 |
22 |
23 | 感谢群友 [@a396901990](https://github.com/a396901990) ,目前已经修复了因为使用simple_permissions导致ios不能编译使用的问题
24 |
25 | xcode10下如果出现 Multiple commands produce这个错误,参考这篇https://www.jianshu.com/p/8a8444acdca5,亲测可以解决。
26 |
27 |
28 | 如果有疑问或者对这个库感兴趣,可以加qq群:854192563一起探讨
29 |
30 | A new flutter plugin project.
31 |
32 | ## Getting Started
33 |
34 | ### 集成高德地图定位android版本
35 |
36 | 1、先申请一个apikey
37 | http://lbs.amap.com/api/android-sdk/guide/create-project/get-key
38 |
39 | 2、修改 `你的项目目录/app/build.gradle`
40 | 在`android/defaultConfig`节点修改`manifestPlaceholders`,新增高德地图key配置
41 |
42 | ```
43 | android {
44 | .... 你的代码
45 |
46 | defaultConfig {
47 | .....
48 | manifestPlaceholders = [
49 | AMAP_KEY : "aa9f0cf8574400f2af0078392c556e25", /// 高德地图key
50 | ]
51 |
52 | }
53 |
54 | ...你的代码
55 |
56 | dependencies {
57 | /// 注意这里需要在主项目增加一条依赖,否则可能发生编译不通过的情况
58 | implementation 'com.amap.api:location:latest.integration'
59 | ...你的代码
60 | }
61 |
62 |
63 | ```
64 |
65 |
66 | ### 集成高德地图定位ios版本
67 |
68 | 1、申请一个key
69 | http://lbs.amap.com/api/ios-sdk/guide/create-project/get-key
70 |
71 | 直接在dart文件中设置key
72 |
73 | ```
74 | import 'package:amap_location/amap_location.dart';
75 |
76 | void main(){
77 | AMapLocationClient.setApiKey("你的key");
78 | runApp(new MyApp());
79 | }
80 | ```
81 |
82 | 2、在info.plist中增加:
83 |
84 | 注意必须要描述清楚app使用定位的目的,苹果审核的时候要看,
85 | 如果写的不清楚,可能会被苹果拒绝上架,作者有过几次惨痛经历 :(
86 |
87 | ```
88 | NSLocationWhenInUseUsageDescription
89 | 要用定位
90 | ```
91 |
92 |
93 | ## 怎么用
94 |
95 | 先导入dart包
96 | 修改pubspec.yaml,增加依赖:
97 |
98 | ```
99 | dependencies:
100 | amap_location:
101 | ```
102 |
103 |
104 | 在要用的地方导入:
105 |
106 | ```
107 | import 'package:amap_location/amap_location.dart';
108 | ```
109 |
110 | 先启动一下
111 |
112 | ```
113 | await AMapLocationClient.startup(new AMapLocationOption( desiredAccuracy:CLLocationAccuracy.kCLLocationAccuracyHundredMeters ));
114 |
115 | ```
116 |
117 | 直接获取定位:
118 |
119 | ```
120 | await AMapLocationClient.getLocation(true)
121 | ```
122 | 监听定位
123 |
124 | ```
125 |
126 | AMapLocationClient.onLocationUpate.listen((AMapLocation loc){
127 | if(!mounted)return;
128 | setState(() {
129 | ...
130 | });
131 | });
132 |
133 | AMapLocationClient.startLocation();
134 |
135 | ```
136 | 停止监听定位
137 | ```
138 | AMapLocationClient.stopLocation();
139 |
140 | ```
141 |
142 | 不要忘了在app生命周期结束的时候关闭
143 | ```
144 | @override
145 | void dispose() {
146 | //注意这里关闭
147 | AMapLocationClient.shutdown();
148 | super.dispose();
149 | }
150 | ```
151 |
152 |
153 | ## 注意点:
154 |
155 | >在android6以上最好手动获取定位权限
156 |
157 | 在example中以simple_permissions这个库为例:
158 |
159 | ```
160 | void _checkPersmission() async{
161 | bool hasPermission = await SimplePermissions.checkPermission(Permission.WhenInUseLocation);
162 | if(!hasPermission){
163 | bool requestPermissionResult = await SimplePermissions.requestPermission(Permission.WhenInUseLocation);
164 | if(!requestPermissionResult){
165 | Alert.alert(context,title: "申请定位权限失败");
166 | return;
167 | }
168 | }
169 | AMapLocationClient.onLocationUpate.listen((AMapLocation loc) {
170 | if (!mounted) return;
171 | setState(() {
172 | location = getLocationStr(loc);
173 | });
174 | });
175 |
176 | AMapLocationClient.startLocation();
177 | }
178 | ```
179 |
180 |
181 |
182 |
183 | ## 特性
184 |
185 | * IOS
186 | * Android
187 | * 直接获取定位
188 | * 监听定位改变
189 |
190 |
191 | ## 下个版本
192 |
193 | * 地理围栏监听
194 |
195 |
196 | This project is a starting point for a Flutter
197 | [plug-in package](https://flutter.io/developing-packages/),
198 | a specialized package that includes platform-specific implementation code for
199 | Android and/or iOS.
200 |
201 | For help getting started with Flutter, view our
202 | [online documentation](https://flutter.io/docs), which offers tutorials,
203 | samples, guidance on mobile development, and a full API reference.
--------------------------------------------------------------------------------
/amap_location.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/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.example.amap_location'
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.2.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 |
36 | dependencies {
37 | implementation 'com.amap.api:location:latest.integration'
38 | }
39 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'amap_location'
2 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
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 |
39 |
40 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java:
--------------------------------------------------------------------------------
1 | package com.jzoom.amaplocation;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.util.Log;
7 |
8 | import com.amap.api.location.AMapLocation;
9 | import com.amap.api.location.AMapLocationClient;
10 | import com.amap.api.location.AMapLocationClientOption;
11 | import com.amap.api.location.AMapLocationListener;
12 |
13 | import java.util.HashMap;
14 | import java.util.Map;
15 |
16 | import io.flutter.plugin.common.MethodChannel;
17 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
18 | import io.flutter.plugin.common.MethodChannel.Result;
19 | import io.flutter.plugin.common.MethodCall;
20 | import io.flutter.plugin.common.PluginRegistry.Registrar;
21 |
22 | /**
23 | * FlutterAmapLocationPlugin
24 | */
25 | public class AmapLocationPlugin implements MethodCallHandler, AMapLocationListener {
26 |
27 |
28 | private Registrar registrar;
29 | private MethodChannel channel;
30 | private AMapLocationClientOption option;
31 | private AMapLocationClient locationClient;
32 | private boolean isLocation;
33 | //备份至
34 | private boolean onceLocation;
35 |
36 | public AmapLocationPlugin(Registrar registrar, MethodChannel channel) {
37 | this.registrar = registrar;
38 | this.channel = channel;
39 | }
40 |
41 | private Activity getActivity(){
42 | return registrar.activity();
43 | }
44 |
45 | private Context getApplicationContext(){
46 | return registrar.activity().getApplicationContext();
47 | }
48 |
49 | /**
50 | * Plugin registration.
51 | */
52 | public static void registerWith(Registrar registrar) {
53 | final MethodChannel channel = new MethodChannel(registrar.messenger(), "amap_location");
54 | channel.setMethodCallHandler(new AmapLocationPlugin(registrar,channel));
55 | }
56 |
57 | @Override
58 | public void onMethodCall(MethodCall call, Result result) {
59 | String method = call.method;
60 |
61 | //显然下面的任何方法都应该放在同步块处理
62 |
63 | if ("startup".equals(method)) {
64 | //启动
65 | result.success(this.startup((Map) call.arguments));
66 |
67 | } else if("shutdown".equals(method)){
68 | //关闭
69 | result.success(this.shutdown());
70 | } else if("getLocation".equals(method)){
71 | boolean needsAddress = (boolean) call.arguments;
72 | this.getLocation(needsAddress,result);
73 | } else if("startLocation".equals(method)){
74 | //启动定位,如果还没有启动,那么返回false
75 | result.success(this.startLocation(this));
76 | } else if("stopLocation".equals(method)){
77 | //停止定位
78 | result.success(this.stopLocation());
79 | } else if("updateOption".equals(method)){
80 | result.success(this.updateOption((Map) call.arguments));
81 | } else if("setApiKey".equals(method)){
82 | result.success(false);
83 | } else {
84 | result.notImplemented();
85 | }
86 | }
87 |
88 |
89 | private boolean getLocation(boolean needsAddress, final Result result) {
90 | synchronized (this){
91 |
92 | if(locationClient==null)return false;
93 |
94 | if(needsAddress!=option.isNeedAddress()){
95 | option.setNeedAddress(needsAddress);
96 | locationClient.setLocationOption(option);
97 | }
98 |
99 | option.setOnceLocation(true);
100 |
101 | final AMapLocationListener listener = new AMapLocationListener() {
102 | @Override
103 | public void onLocationChanged(AMapLocation aMapLocation) {
104 | //恢复原来的值
105 | option.setOnceLocation(onceLocation);
106 | result.success(resultToMap(aMapLocation));
107 | stopLocation();
108 | }
109 | };
110 |
111 | startLocation(listener);
112 |
113 | return true;
114 | }
115 | }
116 |
117 | private static final String TAG = "AmapLocationPugin";
118 |
119 | private Map resultToMap(AMapLocation a){
120 |
121 | Map map = new HashMap();
122 |
123 | if(a!=null) {
124 |
125 | if (a.getErrorCode() != 0) {
126 | //错误信息
127 |
128 | map.put("description", a.getErrorInfo());
129 | map.put("success",false);
130 |
131 | }else{
132 | map.put("success",true);
133 |
134 |
135 | map.put("accuracy", a.getAccuracy());
136 | map.put("altitude", a.getAltitude());
137 | map.put("speed", a.getSpeed());
138 | map.put("timestamp", (double) a.getTime() / 1000);
139 | map.put("latitude", a.getLatitude());
140 | map.put("longitude", a.getLongitude());
141 | map.put("locationType", a.getLocationType());
142 | map.put("provider",a.getProvider());
143 |
144 |
145 | map.put("formattedAddress",a.getAddress());
146 | map.put("country",a.getCountry());
147 | map.put("province",a.getProvince());
148 | map.put("city",a.getCity());
149 | map.put("district",a.getDistrict());
150 | map.put("citycode",a.getCityCode());
151 | map.put("adcode",a.getAdCode());
152 | map.put("street",a.getStreet());
153 | map.put("number",a.getStreetNum());
154 | map.put("POIName",a.getPoiName());
155 | map.put("AOIName",a.getAoiName());
156 |
157 | }
158 |
159 | map.put("code", a.getErrorCode());
160 |
161 | Log.d(TAG,"定位获取结果:"+a.getLatitude() + " code:"+a.getErrorCode() + " 省:"+a.getProvince());
162 |
163 |
164 |
165 |
166 |
167 |
168 | }
169 |
170 | return map;
171 | }
172 |
173 | private boolean stopLocation() {
174 | synchronized (this){
175 | if(locationClient==null){
176 | return false;
177 | }
178 | locationClient.stopLocation();
179 | isLocation = false;
180 | return true;
181 | }
182 |
183 | }
184 |
185 | private boolean shutdown() {
186 | synchronized (this){
187 | if(locationClient!=null){
188 | locationClient.stopLocation();
189 | locationClient = null;
190 | option = null;
191 | return true;
192 | }
193 | return false;
194 | }
195 |
196 |
197 | }
198 |
199 | private boolean startLocation(AMapLocationListener listener){
200 | synchronized (this){
201 | if(locationClient==null){
202 | return false;
203 | }
204 |
205 | if(listener==this){
206 | //持续定位
207 |
208 |
209 | }else{
210 | //单次定位
211 |
212 | }
213 |
214 | locationClient.setLocationListener(listener);
215 | locationClient.startLocation();
216 | isLocation = true;
217 | return true;
218 | }
219 |
220 | }
221 |
222 | private boolean startup(Map arguments) {
223 | synchronized (this){
224 |
225 | if(locationClient==null){
226 | //初始化client
227 | locationClient = new AMapLocationClient(getApplicationContext());
228 | //设置定位参数
229 | AMapLocationClientOption option = new AMapLocationClientOption();
230 | parseOptions(option,arguments);
231 | locationClient.setLocationOption(option);
232 |
233 | //将option保存一下
234 | this.option = option;
235 |
236 | return true;
237 | }
238 |
239 | return false;
240 | }
241 | }
242 |
243 | private boolean updateOption(Map arguments){
244 | synchronized (this){
245 | if(locationClient==null)return false;
246 |
247 | parseOptions(option,arguments);
248 | locationClient.setLocationOption(option);
249 |
250 | return true;
251 | }
252 | }
253 |
254 | /**
255 | * this.locationMode : AMapLocationMode.Hight_Accuracy,
256 | this.gpsFirst:false,
257 | this.httpTimeOut:10000, //30有点长,特殊情况才需要这么长,改成10
258 | this.interval:2000,
259 | this.needsAddress : true,
260 | this.onceLocation : false,
261 | this.onceLocationLatest : false,
262 | this.locationProtocal : AMapLocationProtocol.HTTP,
263 | this.sensorEnable : false,
264 | this.wifiScan : true,
265 | this.locationCacheEnable : true,
266 |
267 | this.allowsBackgroundLocationUpdates : false,
268 | this.desiredAccuracy : CLLocationAccuracy.kCLLocationAccuracyBest,
269 | this.locatingWithReGeocode : false,
270 | this.locationTimeout : 10000, //30有点长,特殊情况才需要这么长,改成10
271 | this.pausesLocationUpdatesAutomatically : false,
272 | this.reGeocodeTimeout : 5000,
273 |
274 |
275 | this.geoLanguage : GeoLanguage.DEFAULT,
276 | * @param arguments
277 | * @return
278 | */
279 | private void parseOptions(AMapLocationClientOption option,Map arguments) {
280 | // AMapLocationClientOption option = new AMapLocationClientOption();
281 | onceLocation = (Boolean) arguments.get("onceLocation");
282 | option.setLocationMode(AMapLocationClientOption.AMapLocationMode.valueOf((String) arguments.get("locationMode")));//可选,设置定位模式,可选的模式有高精度、仅设备、仅网络。默认为高精度模式
283 | option.setGpsFirst( (Boolean)arguments.get("gpsFirst") );//可选,设置是否gps优先,只在高精度模式下有效。默认关闭
284 | option.setHttpTimeOut( (Integer) arguments.get("httpTimeOut"));//可选,设置网络请求超时时间。默认为30秒。在仅设备模式下无效
285 | option.setInterval((Integer) arguments.get("interval"));//可选,设置定位间隔。默认为2秒
286 | option.setNeedAddress((Boolean) arguments.get("needsAddress"));//可选,设置是否返回逆地理地址信息。默认是true
287 | option.setOnceLocation(onceLocation);//可选,设置是否单次定位。默认是false
288 | option.setOnceLocationLatest((Boolean) arguments.get("onceLocationLatest"));//可选,设置是否等待wifi刷新,默认为false.如果设置为true,会自动变为单次定位,持续定位时不要使用
289 | AMapLocationClientOption.setLocationProtocol(AMapLocationClientOption.AMapLocationProtocol.valueOf((String) arguments.get("locationProtocal")));//可选, 设置网络请求的协议。可选HTTP或者HTTPS。默认为HTTP
290 | option.setSensorEnable((Boolean) arguments.get("sensorEnable"));//可选,设置是否使用传感器。默认是false
291 | option.setWifiScan((Boolean) arguments.get("wifiScan")); //可选,设置是否开启wifi扫描。默认为true,如果设置为false会同时停止主动刷新,停止以后完全依赖于系统刷新,定位位置可能存在误差
292 | option.setLocationCacheEnable((Boolean) arguments.get("locationCacheEnable")); //可选,设置是否使用缓存定位,默认为true
293 | option.setGeoLanguage(AMapLocationClientOption.GeoLanguage.valueOf((String) arguments.get("geoLanguage")));//可选,设置逆地理信息的语言,默认值为默认语言(根据所在地区选择语言)
294 |
295 | }
296 |
297 |
298 | @Override
299 | public void onLocationChanged(AMapLocation aMapLocation) {
300 |
301 | synchronized (this){
302 | if(channel==null)return;
303 | Map data = new HashMap<>();
304 | channel.invokeMethod("updateLocation",resultToMap(aMapLocation));
305 | }
306 | }
307 | }
308 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # Visual Studio Code related
19 | .vscode/
20 |
21 | # Flutter/Dart/Pub related
22 | **/doc/api/
23 | .dart_tool/
24 | .flutter-plugins
25 | .packages
26 | .pub-cache/
27 | .pub/
28 | /build/
29 |
30 | # Android related
31 | **/android/**/gradle-wrapper.jar
32 | **/android/.gradle
33 | **/android/captures/
34 | **/android/gradlew
35 | **/android/gradlew.bat
36 | **/android/local.properties
37 | **/android/**/GeneratedPluginRegistrant.java
38 |
39 | # iOS/XCode related
40 | **/ios/**/*.mode1v3
41 | **/ios/**/*.mode2v3
42 | **/ios/**/*.moved-aside
43 | **/ios/**/*.pbxuser
44 | **/ios/**/*.perspectivev3
45 | **/ios/**/*sync/
46 | **/ios/**/.sconsign.dblite
47 | **/ios/**/.tags*
48 | **/ios/**/.vagrant/
49 | **/ios/**/DerivedData/
50 | **/ios/**/Icon?
51 | **/ios/**/Pods/
52 | **/ios/**/.symlinks/
53 | **/ios/**/profile
54 | **/ios/**/xcuserdata
55 | **/ios/.generated/
56 | **/ios/Flutter/App.framework
57 | **/ios/Flutter/Flutter.framework
58 | **/ios/Flutter/Generated.xcconfig
59 | **/ios/Flutter/app.flx
60 | **/ios/Flutter/app.zip
61 | **/ios/Flutter/flutter_assets/
62 | **/ios/ServiceDefinitions.json
63 | **/ios/Runner/GeneratedPluginRegistrant.*
64 |
65 | # Exceptions to above rules.
66 | !**/ios/**/default.mode1v3
67 | !**/ios/**/default.mode2v3
68 | !**/ios/**/default.pbxuser
69 | !**/ios/**/default.perspectivev3
70 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
71 |
--------------------------------------------------------------------------------
/example/.idea/libraries/Dart_SDK.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/example/.idea/libraries/Flutter_for_Android.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/example/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/example/.idea/runConfigurations/main_dart.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/example/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/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: 8661d8aecd626f7f57ccbcb735553edc05a2e713
8 | channel: stable
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # amap_location_example
2 |
3 | Demonstrates how to use the amap_location plugin.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://flutter.io/docs/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook)
13 |
14 | For help getting started with Flutter, view our
15 | [online documentation](https://flutter.io/docs), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/example/amap_location_example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/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 |
36 | applicationId "com.jzoom.amaplocationexample"
37 | minSdkVersion 16
38 | targetSdkVersion 28
39 | versionCode flutterVersionCode.toInteger()
40 | versionName flutterVersionName
41 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
42 |
43 | manifestPlaceholders = [
44 | AMAP_KEY : "aa9f0cf8574400f2af0078392c556e25", /// 高德地图key
45 | ]
46 | }
47 |
48 | signingConfigs {
49 | release {
50 | keyAlias 'flutter_amap'
51 | keyPassword '123456'
52 | storeFile file('flutter_amap_location_example.keystore')
53 | storePassword '123456'
54 | }
55 | debug {
56 | keyAlias 'flutter_amap'
57 | keyPassword '123456'
58 | storeFile file('flutter_amap_location_example.keystore')
59 | storePassword '123456'
60 | }
61 | }
62 |
63 | buildTypes {
64 | release {
65 | // TODO: Add your own signing config for the release build.
66 | // Signing with the debug keys for now, so `flutter run --release` works.
67 | signingConfig signingConfigs.release
68 | }
69 | }
70 | }
71 |
72 | flutter {
73 | source '../..'
74 | }
75 |
76 | dependencies {
77 | implementation 'com.amap.api:location:latest.integration'
78 | testImplementation 'junit:junit:4.12'
79 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
80 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
81 | }
82 |
--------------------------------------------------------------------------------
/example/android/app/flutter_amap_location_example.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/example/android/app/flutter_amap_location_example.keystore
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
13 |
20 |
24 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/example/amap_location_example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.amap_location_example;
2 |
3 | import android.os.Bundle;
4 | import io.flutter.app.FlutterActivity;
5 | import io.flutter.plugins.GeneratedPluginRegistrant;
6 |
7 | public class MainActivity extends FlutterActivity {
8 | @Override
9 | protected void onCreate(Bundle savedInstanceState) {
10 | super.onCreate(savedInstanceState);
11 | GeneratedPluginRegistrant.registerWith(this);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | google()
4 | jcenter()
5 | }
6 |
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:3.2.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 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/example/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/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-4.10.2-all.zip
7 |
--------------------------------------------------------------------------------
/example/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 |
--------------------------------------------------------------------------------
/example/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 |
--------------------------------------------------------------------------------
/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/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/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 parse_KV_file(file, separator='=')
14 | file_abs_path = File.expand_path(file)
15 | if !File.exists? file_abs_path
16 | return [];
17 | end
18 | pods_ary = []
19 | skip_line_start_symbols = ["#", "/"]
20 | File.foreach(file_abs_path) { |line|
21 | next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
22 | plugin = line.split(pattern=separator)
23 | if plugin.length == 2
24 | podname = plugin[0].strip()
25 | path = plugin[1].strip()
26 | podpath = File.expand_path("#{path}", file_abs_path)
27 | pods_ary.push({:name => podname, :path => podpath});
28 | else
29 | puts "Invalid plugin specification: #{line}"
30 | end
31 | }
32 | return pods_ary
33 | end
34 |
35 | target 'Runner' do
36 | # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
37 | # referring to absolute paths on developers' machines.
38 | system('rm -rf .symlinks')
39 | system('mkdir -p .symlinks/plugins')
40 |
41 | # Flutter Pods
42 | generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
43 | if generated_xcode_build_settings.empty?
44 | puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
45 | end
46 | generated_xcode_build_settings.map { |p|
47 | if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
48 | symlink = File.join('.symlinks', 'flutter')
49 | File.symlink(File.dirname(p[:path]), symlink)
50 | pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
51 | end
52 | }
53 |
54 | # Plugin Pods
55 | plugin_pods = parse_KV_file('../.flutter-plugins')
56 | plugin_pods.map { |p|
57 | symlink = File.join('.symlinks', 'plugins', p[:name])
58 | File.symlink(p[:path], symlink)
59 | pod p[:name], :path => File.join(symlink, 'ios')
60 | }
61 | end
62 |
63 | post_install do |installer|
64 | installer.pods_project.targets.each do |target|
65 | target.build_configurations.each do |config|
66 | config.build_settings['ENABLE_BITCODE'] = 'NO'
67 | end
68 | end
69 | end
70 |
--------------------------------------------------------------------------------
/example/ios/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - amap_location (0.0.1):
3 | - AMapLocation
4 | - Flutter
5 | - AMapFoundation (1.5.6)
6 | - AMapLocation (2.6.1):
7 | - AMapFoundation (~> 1.4)
8 | - Flutter (1.0.0)
9 | - simple_permissions (0.0.1):
10 | - Flutter
11 |
12 | DEPENDENCIES:
13 | - amap_location (from `.symlinks/plugins/amap_location/ios`)
14 | - Flutter (from `.symlinks/flutter/ios`)
15 | - simple_permissions (from `.symlinks/plugins/simple_permissions/ios`)
16 |
17 | SPEC REPOS:
18 | https://github.com/cocoapods/specs.git:
19 | - AMapFoundation
20 | - AMapLocation
21 |
22 | EXTERNAL SOURCES:
23 | amap_location:
24 | :path: ".symlinks/plugins/amap_location/ios"
25 | Flutter:
26 | :path: ".symlinks/flutter/ios"
27 | simple_permissions:
28 | :path: ".symlinks/plugins/simple_permissions/ios"
29 |
30 | SPEC CHECKSUMS:
31 | amap_location: 738b2c0fb7c62b26af20ebc65018b7bdc0bd7a6d
32 | AMapFoundation: 20fce2a12cd152e1092afdd04379cdac21932185
33 | AMapLocation: cf024b53dc03663efb4ea4bcce27d4cce58bb97a
34 | Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296
35 | simple_permissions: 8ea52208b437f8fae29d97a55fe00b705a53246b
36 |
37 | PODFILE CHECKSUM: aff02bfeed411c636180d6812254b2daeea14d09
38 |
39 | COCOAPODS: 1.5.3
40 |
--------------------------------------------------------------------------------
/example/ios/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // Use this file to import your target's public headers that you would like to expose to Swift.
3 | //
4 |
5 |
--------------------------------------------------------------------------------
/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 | 3A01460F39AE43C72CBEB7CC /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A6E33648474D590B417279F /* libPods-Runner.a */; };
12 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
13 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
14 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
15 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
16 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
17 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
18 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
19 | 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
20 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
21 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
22 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
23 | D5C76C58225491F100547C5C /* bridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5C76C57225491F100547C5C /* bridge.swift */; };
24 | /* End PBXBuildFile section */
25 |
26 | /* Begin PBXCopyFilesBuildPhase section */
27 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = {
28 | isa = PBXCopyFilesBuildPhase;
29 | buildActionMask = 2147483647;
30 | dstPath = "";
31 | dstSubfolderSpec = 10;
32 | files = (
33 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
34 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
35 | );
36 | name = "Embed Frameworks";
37 | runOnlyForDeploymentPostprocessing = 0;
38 | };
39 | /* End PBXCopyFilesBuildPhase section */
40 |
41 | /* Begin PBXFileReference section */
42 | 0A6E33648474D590B417279F /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
43 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
44 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
45 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
46 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; };
47 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
48 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
49 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
50 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; };
51 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; };
52 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; };
53 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
54 | 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
55 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
56 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
57 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
58 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
59 | D5C76C56225491F000547C5C /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; };
60 | D5C76C57225491F100547C5C /* bridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = bridge.swift; sourceTree = ""; };
61 | /* End PBXFileReference section */
62 |
63 | /* Begin PBXFrameworksBuildPhase section */
64 | 97C146EB1CF9000F007C117D /* Frameworks */ = {
65 | isa = PBXFrameworksBuildPhase;
66 | buildActionMask = 2147483647;
67 | files = (
68 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
69 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
70 | 3A01460F39AE43C72CBEB7CC /* libPods-Runner.a in Frameworks */,
71 | );
72 | runOnlyForDeploymentPostprocessing = 0;
73 | };
74 | /* End PBXFrameworksBuildPhase section */
75 |
76 | /* Begin PBXGroup section */
77 | 181A1F4DDE5BC9E7871C5FFC /* Pods */ = {
78 | isa = PBXGroup;
79 | children = (
80 | );
81 | name = Pods;
82 | sourceTree = "";
83 | };
84 | 464CAC4CEA07AC905A088A44 /* Frameworks */ = {
85 | isa = PBXGroup;
86 | children = (
87 | 0A6E33648474D590B417279F /* libPods-Runner.a */,
88 | );
89 | name = Frameworks;
90 | sourceTree = "";
91 | };
92 | 9740EEB11CF90186004384FC /* Flutter */ = {
93 | isa = PBXGroup;
94 | children = (
95 | 3B80C3931E831B6300D905FE /* App.framework */,
96 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
97 | 9740EEBA1CF902C7004384FC /* Flutter.framework */,
98 | 9740EEB21CF90195004384FC /* Debug.xcconfig */,
99 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
100 | 9740EEB31CF90195004384FC /* Generated.xcconfig */,
101 | D5C76C57225491F100547C5C /* bridge.swift */,
102 | D5C76C56225491F000547C5C /* Runner-Bridging-Header.h */,
103 | );
104 | name = Flutter;
105 | sourceTree = "";
106 | };
107 | 97C146E51CF9000F007C117D = {
108 | isa = PBXGroup;
109 | children = (
110 | 9740EEB11CF90186004384FC /* Flutter */,
111 | 97C146F01CF9000F007C117D /* Runner */,
112 | 97C146EF1CF9000F007C117D /* Products */,
113 | 181A1F4DDE5BC9E7871C5FFC /* Pods */,
114 | 464CAC4CEA07AC905A088A44 /* Frameworks */,
115 | );
116 | sourceTree = "";
117 | };
118 | 97C146EF1CF9000F007C117D /* Products */ = {
119 | isa = PBXGroup;
120 | children = (
121 | 97C146EE1CF9000F007C117D /* Runner.app */,
122 | );
123 | name = Products;
124 | sourceTree = "";
125 | };
126 | 97C146F01CF9000F007C117D /* Runner */ = {
127 | isa = PBXGroup;
128 | children = (
129 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
130 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
131 | 97C146FA1CF9000F007C117D /* Main.storyboard */,
132 | 97C146FD1CF9000F007C117D /* Assets.xcassets */,
133 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
134 | 97C147021CF9000F007C117D /* Info.plist */,
135 | 97C146F11CF9000F007C117D /* Supporting Files */,
136 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
137 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
138 | );
139 | path = Runner;
140 | sourceTree = "";
141 | };
142 | 97C146F11CF9000F007C117D /* Supporting Files */ = {
143 | isa = PBXGroup;
144 | children = (
145 | 97C146F21CF9000F007C117D /* main.m */,
146 | );
147 | name = "Supporting Files";
148 | sourceTree = "";
149 | };
150 | /* End PBXGroup section */
151 |
152 | /* Begin PBXNativeTarget section */
153 | 97C146ED1CF9000F007C117D /* Runner */ = {
154 | isa = PBXNativeTarget;
155 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
156 | buildPhases = (
157 | 28B732E02AF94952FDBE1463 /* [CP] Check Pods Manifest.lock */,
158 | 9740EEB61CF901F6004384FC /* Run Script */,
159 | 97C146EA1CF9000F007C117D /* Sources */,
160 | 97C146EB1CF9000F007C117D /* Frameworks */,
161 | 97C146EC1CF9000F007C117D /* Resources */,
162 | 9705A1C41CF9048500538489 /* Embed Frameworks */,
163 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */,
164 | 76837CC4314A802D2E00CFB6 /* [CP] Embed Pods Frameworks */,
165 | );
166 | buildRules = (
167 | );
168 | dependencies = (
169 | );
170 | name = Runner;
171 | productName = Runner;
172 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
173 | productType = "com.apple.product-type.application";
174 | };
175 | /* End PBXNativeTarget section */
176 |
177 | /* Begin PBXProject section */
178 | 97C146E61CF9000F007C117D /* Project object */ = {
179 | isa = PBXProject;
180 | attributes = {
181 | LastUpgradeCheck = 0910;
182 | ORGANIZATIONNAME = "The Chromium Authors";
183 | TargetAttributes = {
184 | 97C146ED1CF9000F007C117D = {
185 | CreatedOnToolsVersion = 7.3.1;
186 | LastSwiftMigration = 1010;
187 | };
188 | };
189 | };
190 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
191 | compatibilityVersion = "Xcode 3.2";
192 | developmentRegion = English;
193 | hasScannedForEncodings = 0;
194 | knownRegions = (
195 | en,
196 | Base,
197 | );
198 | mainGroup = 97C146E51CF9000F007C117D;
199 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
200 | projectDirPath = "";
201 | projectRoot = "";
202 | targets = (
203 | 97C146ED1CF9000F007C117D /* Runner */,
204 | );
205 | };
206 | /* End PBXProject section */
207 |
208 | /* Begin PBXResourcesBuildPhase section */
209 | 97C146EC1CF9000F007C117D /* Resources */ = {
210 | isa = PBXResourcesBuildPhase;
211 | buildActionMask = 2147483647;
212 | files = (
213 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
214 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
215 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
216 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
217 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
218 | );
219 | runOnlyForDeploymentPostprocessing = 0;
220 | };
221 | /* End PBXResourcesBuildPhase section */
222 |
223 | /* Begin PBXShellScriptBuildPhase section */
224 | 28B732E02AF94952FDBE1463 /* [CP] Check Pods Manifest.lock */ = {
225 | isa = PBXShellScriptBuildPhase;
226 | buildActionMask = 2147483647;
227 | files = (
228 | );
229 | inputPaths = (
230 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
231 | "${PODS_ROOT}/Manifest.lock",
232 | );
233 | name = "[CP] Check Pods Manifest.lock";
234 | outputPaths = (
235 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
236 | );
237 | runOnlyForDeploymentPostprocessing = 0;
238 | shellPath = /bin/sh;
239 | 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";
240 | showEnvVarsInLog = 0;
241 | };
242 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
243 | isa = PBXShellScriptBuildPhase;
244 | buildActionMask = 2147483647;
245 | files = (
246 | );
247 | inputPaths = (
248 | );
249 | name = "Thin Binary";
250 | outputPaths = (
251 | );
252 | runOnlyForDeploymentPostprocessing = 0;
253 | shellPath = /bin/sh;
254 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
255 | };
256 | 76837CC4314A802D2E00CFB6 /* [CP] Embed Pods Frameworks */ = {
257 | isa = PBXShellScriptBuildPhase;
258 | buildActionMask = 2147483647;
259 | files = (
260 | );
261 | inputPaths = (
262 | "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
263 | "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
264 | );
265 | name = "[CP] Embed Pods Frameworks";
266 | outputPaths = (
267 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
268 | );
269 | runOnlyForDeploymentPostprocessing = 0;
270 | shellPath = /bin/sh;
271 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
272 | showEnvVarsInLog = 0;
273 | };
274 | 9740EEB61CF901F6004384FC /* Run Script */ = {
275 | isa = PBXShellScriptBuildPhase;
276 | buildActionMask = 2147483647;
277 | files = (
278 | );
279 | inputPaths = (
280 | );
281 | name = "Run Script";
282 | outputPaths = (
283 | );
284 | runOnlyForDeploymentPostprocessing = 0;
285 | shellPath = /bin/sh;
286 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
287 | };
288 | /* End PBXShellScriptBuildPhase section */
289 |
290 | /* Begin PBXSourcesBuildPhase section */
291 | 97C146EA1CF9000F007C117D /* Sources */ = {
292 | isa = PBXSourcesBuildPhase;
293 | buildActionMask = 2147483647;
294 | files = (
295 | D5C76C58225491F100547C5C /* bridge.swift in Sources */,
296 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */,
297 | 97C146F31CF9000F007C117D /* main.m in Sources */,
298 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
299 | );
300 | runOnlyForDeploymentPostprocessing = 0;
301 | };
302 | /* End PBXSourcesBuildPhase section */
303 |
304 | /* Begin PBXVariantGroup section */
305 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = {
306 | isa = PBXVariantGroup;
307 | children = (
308 | 97C146FB1CF9000F007C117D /* Base */,
309 | );
310 | name = Main.storyboard;
311 | sourceTree = "";
312 | };
313 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
314 | isa = PBXVariantGroup;
315 | children = (
316 | 97C147001CF9000F007C117D /* Base */,
317 | );
318 | name = LaunchScreen.storyboard;
319 | sourceTree = "";
320 | };
321 | /* End PBXVariantGroup section */
322 |
323 | /* Begin XCBuildConfiguration section */
324 | 249021D3217E4FDB00AE95B9 /* Profile */ = {
325 | isa = XCBuildConfiguration;
326 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
327 | buildSettings = {
328 | ALWAYS_SEARCH_USER_PATHS = NO;
329 | CLANG_ANALYZER_NONNULL = YES;
330 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
331 | CLANG_CXX_LIBRARY = "libc++";
332 | CLANG_ENABLE_MODULES = YES;
333 | CLANG_ENABLE_OBJC_ARC = YES;
334 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
335 | CLANG_WARN_BOOL_CONVERSION = YES;
336 | CLANG_WARN_COMMA = YES;
337 | CLANG_WARN_CONSTANT_CONVERSION = YES;
338 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
339 | CLANG_WARN_EMPTY_BODY = YES;
340 | CLANG_WARN_ENUM_CONVERSION = YES;
341 | CLANG_WARN_INFINITE_RECURSION = YES;
342 | CLANG_WARN_INT_CONVERSION = YES;
343 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
344 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
345 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
346 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
347 | CLANG_WARN_STRICT_PROTOTYPES = YES;
348 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
349 | CLANG_WARN_UNREACHABLE_CODE = YES;
350 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
351 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
352 | COPY_PHASE_STRIP = NO;
353 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
354 | ENABLE_NS_ASSERTIONS = NO;
355 | ENABLE_STRICT_OBJC_MSGSEND = YES;
356 | GCC_C_LANGUAGE_STANDARD = gnu99;
357 | GCC_NO_COMMON_BLOCKS = YES;
358 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
359 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
360 | GCC_WARN_UNDECLARED_SELECTOR = YES;
361 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
362 | GCC_WARN_UNUSED_FUNCTION = YES;
363 | GCC_WARN_UNUSED_VARIABLE = YES;
364 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
365 | MTL_ENABLE_DEBUG_INFO = NO;
366 | SDKROOT = iphoneos;
367 | TARGETED_DEVICE_FAMILY = "1,2";
368 | VALIDATE_PRODUCT = YES;
369 | };
370 | name = Profile;
371 | };
372 | 249021D4217E4FDB00AE95B9 /* Profile */ = {
373 | isa = XCBuildConfiguration;
374 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
375 | buildSettings = {
376 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
377 | CLANG_ENABLE_MODULES = YES;
378 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
379 | DEVELOPMENT_TEAM = S8QB4VV633;
380 | ENABLE_BITCODE = NO;
381 | FRAMEWORK_SEARCH_PATHS = (
382 | "$(inherited)",
383 | "$(PROJECT_DIR)/Flutter",
384 | );
385 | INFOPLIST_FILE = Runner/Info.plist;
386 | IPHONEOS_DEPLOYMENT_TARGET = 11.0;
387 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
388 | LIBRARY_SEARCH_PATHS = (
389 | "$(inherited)",
390 | "$(PROJECT_DIR)/Flutter",
391 | );
392 | PRODUCT_BUNDLE_IDENTIFIER = com.jzoom.amapLocationExample;
393 | PRODUCT_NAME = "$(TARGET_NAME)";
394 | SWIFT_OBJC_BRIDGING_HEADER = "Runner-Bridging-Header.h";
395 | SWIFT_VERSION = 4.2;
396 | VERSIONING_SYSTEM = "apple-generic";
397 | };
398 | name = Profile;
399 | };
400 | 97C147031CF9000F007C117D /* Debug */ = {
401 | isa = XCBuildConfiguration;
402 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
403 | buildSettings = {
404 | ALWAYS_SEARCH_USER_PATHS = NO;
405 | CLANG_ANALYZER_NONNULL = YES;
406 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
407 | CLANG_CXX_LIBRARY = "libc++";
408 | CLANG_ENABLE_MODULES = YES;
409 | CLANG_ENABLE_OBJC_ARC = YES;
410 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
411 | CLANG_WARN_BOOL_CONVERSION = YES;
412 | CLANG_WARN_COMMA = YES;
413 | CLANG_WARN_CONSTANT_CONVERSION = YES;
414 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
415 | CLANG_WARN_EMPTY_BODY = YES;
416 | CLANG_WARN_ENUM_CONVERSION = YES;
417 | CLANG_WARN_INFINITE_RECURSION = YES;
418 | CLANG_WARN_INT_CONVERSION = YES;
419 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
420 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
421 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
422 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
423 | CLANG_WARN_STRICT_PROTOTYPES = YES;
424 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
425 | CLANG_WARN_UNREACHABLE_CODE = YES;
426 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
427 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
428 | COPY_PHASE_STRIP = NO;
429 | DEBUG_INFORMATION_FORMAT = dwarf;
430 | ENABLE_STRICT_OBJC_MSGSEND = YES;
431 | ENABLE_TESTABILITY = YES;
432 | GCC_C_LANGUAGE_STANDARD = gnu99;
433 | GCC_DYNAMIC_NO_PIC = NO;
434 | GCC_NO_COMMON_BLOCKS = YES;
435 | GCC_OPTIMIZATION_LEVEL = 0;
436 | GCC_PREPROCESSOR_DEFINITIONS = (
437 | "DEBUG=1",
438 | "$(inherited)",
439 | );
440 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
441 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
442 | GCC_WARN_UNDECLARED_SELECTOR = YES;
443 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
444 | GCC_WARN_UNUSED_FUNCTION = YES;
445 | GCC_WARN_UNUSED_VARIABLE = YES;
446 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
447 | MTL_ENABLE_DEBUG_INFO = YES;
448 | ONLY_ACTIVE_ARCH = YES;
449 | SDKROOT = iphoneos;
450 | TARGETED_DEVICE_FAMILY = "1,2";
451 | };
452 | name = Debug;
453 | };
454 | 97C147041CF9000F007C117D /* Release */ = {
455 | isa = XCBuildConfiguration;
456 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
457 | buildSettings = {
458 | ALWAYS_SEARCH_USER_PATHS = NO;
459 | CLANG_ANALYZER_NONNULL = YES;
460 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
461 | CLANG_CXX_LIBRARY = "libc++";
462 | CLANG_ENABLE_MODULES = YES;
463 | CLANG_ENABLE_OBJC_ARC = YES;
464 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
465 | CLANG_WARN_BOOL_CONVERSION = YES;
466 | CLANG_WARN_COMMA = YES;
467 | CLANG_WARN_CONSTANT_CONVERSION = YES;
468 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
469 | CLANG_WARN_EMPTY_BODY = YES;
470 | CLANG_WARN_ENUM_CONVERSION = YES;
471 | CLANG_WARN_INFINITE_RECURSION = YES;
472 | CLANG_WARN_INT_CONVERSION = YES;
473 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
474 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
475 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
476 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
477 | CLANG_WARN_STRICT_PROTOTYPES = YES;
478 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
479 | CLANG_WARN_UNREACHABLE_CODE = YES;
480 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
481 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
482 | COPY_PHASE_STRIP = NO;
483 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
484 | ENABLE_NS_ASSERTIONS = NO;
485 | ENABLE_STRICT_OBJC_MSGSEND = YES;
486 | GCC_C_LANGUAGE_STANDARD = gnu99;
487 | GCC_NO_COMMON_BLOCKS = YES;
488 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
489 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
490 | GCC_WARN_UNDECLARED_SELECTOR = YES;
491 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
492 | GCC_WARN_UNUSED_FUNCTION = YES;
493 | GCC_WARN_UNUSED_VARIABLE = YES;
494 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
495 | MTL_ENABLE_DEBUG_INFO = NO;
496 | SDKROOT = iphoneos;
497 | TARGETED_DEVICE_FAMILY = "1,2";
498 | VALIDATE_PRODUCT = YES;
499 | };
500 | name = Release;
501 | };
502 | 97C147061CF9000F007C117D /* Debug */ = {
503 | isa = XCBuildConfiguration;
504 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
505 | buildSettings = {
506 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
507 | CLANG_ENABLE_MODULES = YES;
508 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
509 | ENABLE_BITCODE = NO;
510 | FRAMEWORK_SEARCH_PATHS = (
511 | "$(inherited)",
512 | "$(PROJECT_DIR)/Flutter",
513 | );
514 | INFOPLIST_FILE = Runner/Info.plist;
515 | IPHONEOS_DEPLOYMENT_TARGET = 11.0;
516 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
517 | LIBRARY_SEARCH_PATHS = (
518 | "$(inherited)",
519 | "$(PROJECT_DIR)/Flutter",
520 | );
521 | PRODUCT_BUNDLE_IDENTIFIER = com.jzoom.amapLocationExample;
522 | PRODUCT_NAME = "$(TARGET_NAME)";
523 | SWIFT_OBJC_BRIDGING_HEADER = "Runner-Bridging-Header.h";
524 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
525 | SWIFT_VERSION = 4.2;
526 | VERSIONING_SYSTEM = "apple-generic";
527 | };
528 | name = Debug;
529 | };
530 | 97C147071CF9000F007C117D /* Release */ = {
531 | isa = XCBuildConfiguration;
532 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
533 | buildSettings = {
534 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
535 | CLANG_ENABLE_MODULES = YES;
536 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
537 | ENABLE_BITCODE = NO;
538 | FRAMEWORK_SEARCH_PATHS = (
539 | "$(inherited)",
540 | "$(PROJECT_DIR)/Flutter",
541 | );
542 | INFOPLIST_FILE = Runner/Info.plist;
543 | IPHONEOS_DEPLOYMENT_TARGET = 11.0;
544 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
545 | LIBRARY_SEARCH_PATHS = (
546 | "$(inherited)",
547 | "$(PROJECT_DIR)/Flutter",
548 | );
549 | PRODUCT_BUNDLE_IDENTIFIER = com.jzoom.amapLocationExample;
550 | PRODUCT_NAME = "$(TARGET_NAME)";
551 | SWIFT_OBJC_BRIDGING_HEADER = "Runner-Bridging-Header.h";
552 | SWIFT_VERSION = 4.2;
553 | VERSIONING_SYSTEM = "apple-generic";
554 | };
555 | name = Release;
556 | };
557 | /* End XCBuildConfiguration section */
558 |
559 | /* Begin XCConfigurationList section */
560 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
561 | isa = XCConfigurationList;
562 | buildConfigurations = (
563 | 97C147031CF9000F007C117D /* Debug */,
564 | 97C147041CF9000F007C117D /* Release */,
565 | 249021D3217E4FDB00AE95B9 /* Profile */,
566 | );
567 | defaultConfigurationIsVisible = 0;
568 | defaultConfigurationName = Release;
569 | };
570 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
571 | isa = XCConfigurationList;
572 | buildConfigurations = (
573 | 97C147061CF9000F007C117D /* Debug */,
574 | 97C147071CF9000F007C117D /* Release */,
575 | 249021D4217E4FDB00AE95B9 /* Profile */,
576 | );
577 | defaultConfigurationIsVisible = 0;
578 | defaultConfigurationName = Release;
579 | };
580 | /* End XCConfigurationList section */
581 | };
582 | rootObject = 97C146E61CF9000F007C117D /* Project object */;
583 | }
584 |
--------------------------------------------------------------------------------
/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.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BuildSystemType
6 | Original
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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/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 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | amap_location_example
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | NSAppTransportSecurity
26 |
27 | NSAllowsArbitraryLoads
28 |
29 |
30 | NSLocationWhenInUseUsageDescription
31 | 需要定位
32 | UIBackgroundModes
33 |
34 | location
35 | remote-notification
36 |
37 | UILaunchStoryboardName
38 | LaunchScreen
39 | UIMainStoryboardFile
40 | Main
41 | UIRequiredDeviceCapabilities
42 |
43 | arm64
44 |
45 | UISupportedInterfaceOrientations
46 |
47 | UIInterfaceOrientationPortrait
48 | UIInterfaceOrientationLandscapeLeft
49 | UIInterfaceOrientationLandscapeRight
50 |
51 | UISupportedInterfaceOrientations~ipad
52 |
53 | UIInterfaceOrientationPortrait
54 | UIInterfaceOrientationPortraitUpsideDown
55 | UIInterfaceOrientationLandscapeLeft
56 | UIInterfaceOrientationLandscapeRight
57 |
58 | UIViewControllerBasedStatusBarAppearance
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/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/ios/bridge.swift:
--------------------------------------------------------------------------------
1 | //
2 | // bridge.swift
3 | // Runner
4 | //
5 | // Created by JZoom on 2019/4/3.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
--------------------------------------------------------------------------------
/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:amap_location/amap_location.dart';
3 | import 'package:simple_permissions/simple_permissions.dart';
4 | import 'package:easy_alert/easy_alert.dart';
5 |
6 | void main() {
7 | /*============*/
8 | //设置ios的key
9 | /*=============*/
10 | AMapLocationClient.setApiKey("a5bae506b2d053ed4ae7827f38b1766d");
11 | /*============*/
12 | //设置ios的key
13 | /*=============*/
14 |
15 | runApp(new MaterialApp(
16 | home: new Home(),
17 | routes: {
18 | "/location/get": (BuildContext context) => new LocationGet(),
19 | "/location/listen": (BuildContext content) => new LocationListen()
20 | },
21 | ));
22 | }
23 |
24 | class _LocationGetState extends State {
25 | AMapLocation _loc;
26 |
27 | @override
28 | Widget build(BuildContext context) {
29 | return new Scaffold(
30 | appBar: new AppBar(
31 | title: new Text('直接获取定位'),
32 | ),
33 | body: new Center(
34 | child: _loc == null
35 | ? new Text("正在定位")
36 | : new Text("定位成功:${_loc.formattedAddress}"),
37 | ));
38 | }
39 |
40 | void _checkPersmission() async {
41 | bool hasPermission =
42 | await SimplePermissions.checkPermission(Permission.WhenInUseLocation);
43 | if (!hasPermission) {
44 | PermissionStatus requestPermissionResult =
45 | await SimplePermissions.requestPermission(
46 | Permission.WhenInUseLocation);
47 | if (requestPermissionResult != PermissionStatus.authorized) {
48 | Alert.alert(context, title: "申请定位权限失败");
49 | return;
50 | }
51 | }
52 | AMapLocation loc = await AMapLocationClient.getLocation(true);
53 | setState(() {
54 | _loc = loc;
55 | });
56 | }
57 |
58 | @override
59 | void initState() {
60 | _checkPersmission();
61 | super.initState();
62 | }
63 |
64 | @override
65 | void dispose() {
66 | //这里可以停止定位
67 | //AMapLocationClient.stopLocation();
68 |
69 | super.dispose();
70 | }
71 | }
72 |
73 | class LocationGet extends StatefulWidget {
74 | @override
75 | State createState() => new _LocationGetState();
76 | }
77 |
78 | String getLocationStr(AMapLocation loc) {
79 | if (loc == null) {
80 | return "正在定位";
81 | }
82 |
83 | if (loc.isSuccess()) {
84 | if (loc.hasAddress()) {
85 | return "定位成功: \n时间${loc.timestamp}\n经纬度:${loc.latitude} ${loc.longitude}\n 地址:${loc.formattedAddress} 城市:${loc.city} 省:${loc.province}";
86 | } else {
87 | return "定位成功: \n时间${loc.timestamp}\n经纬度:${loc.latitude} ${loc.longitude}\n ";
88 | }
89 | } else {
90 | return "定位失败: \n错误:{code=${loc.code},description=${loc.description}";
91 | }
92 | }
93 |
94 | class _LocationListenState extends State {
95 | String location;
96 |
97 | @override
98 | Widget build(BuildContext context) {
99 | return new Scaffold(
100 | appBar: new AppBar(
101 | title: new Text('监听定位改变'),
102 | ),
103 | body: new Center(
104 | child: new Text(location),
105 | ));
106 | }
107 |
108 | void _checkPersmission() async {
109 | bool hasPermission =
110 | await SimplePermissions.checkPermission(Permission.WhenInUseLocation);
111 | if (!hasPermission) {
112 | PermissionStatus requestPermissionResult =
113 | await SimplePermissions.requestPermission(
114 | Permission.WhenInUseLocation);
115 | if (requestPermissionResult != PermissionStatus.authorized) {
116 | Alert.alert(context, title: "申请定位权限失败");
117 | return;
118 | }
119 | }
120 | AMapLocationClient.onLocationUpate.listen((AMapLocation loc) {
121 | if (!mounted) return;
122 | setState(() {
123 | location = getLocationStr(loc);
124 | });
125 | });
126 |
127 | AMapLocationClient.startLocation();
128 | }
129 |
130 | @override
131 | void initState() {
132 | location = getLocationStr(null);
133 | _checkPersmission();
134 |
135 | super.initState();
136 | }
137 |
138 | @override
139 | void dispose() {
140 | //注意这里停止监听
141 | AMapLocationClient.stopLocation();
142 | super.dispose();
143 | }
144 | }
145 |
146 | class LocationListen extends StatefulWidget {
147 | @override
148 | State createState() => new _LocationListenState();
149 | }
150 |
151 | class _HomeState extends State {
152 | @override
153 | void initState() {
154 | //启动客户端,这里设置ios端的精度小一点
155 | AMapLocationClient.startup(new AMapLocationOption(
156 | desiredAccuracy: CLLocationAccuracy.kCLLocationAccuracyHundredMeters));
157 | super.initState();
158 | }
159 |
160 | @override
161 | void dispose() {
162 | //注意这里关闭
163 | AMapLocationClient.shutdown();
164 | super.dispose();
165 | }
166 |
167 | List render(BuildContext context, List children) {
168 | return ListTile.divideTiles(
169 | context: context,
170 | tiles: children.map((dynamic data) {
171 | return buildListTile(
172 | context, data["title"], data["subtitle"], data["url"]);
173 | })).toList();
174 | }
175 |
176 | Widget buildListTile(
177 | BuildContext context, String title, String subtitle, String url) {
178 | return new ListTile(
179 | onTap: () {
180 | Navigator.of(context).pushNamed(url);
181 | },
182 | isThreeLine: true,
183 | dense: false,
184 | leading: null,
185 | title: new Text(title),
186 | subtitle: new Text(subtitle),
187 | trailing: new Icon(
188 | Icons.arrow_right,
189 | color: Colors.blueAccent,
190 | ),
191 | );
192 | }
193 |
194 | @override
195 | Widget build(BuildContext context) {
196 | return new Scaffold(
197 | appBar: new AppBar(
198 | title: new Text('高德地图定位'),
199 | ),
200 | body: new Scrollbar(
201 | child: new ListView(
202 | children: render(context, [
203 | {
204 | "title": "直接获取定位",
205 | "subtitle": "不需要先启用监听就可以直接获取定位",
206 | "url": "/location/get"
207 | },
208 | {"title": "监听定位", "subtitle": "启动定位改变监听", "url": "/location/listen"}
209 | ]),
210 | )));
211 | }
212 | }
213 |
214 | class Home extends StatefulWidget {
215 | @override
216 | State createState() {
217 | return new _HomeState();
218 | }
219 | }
220 |
--------------------------------------------------------------------------------
/example/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://www.dartlang.org/tools/pub/glossary#lockfile
3 | packages:
4 | amap_location:
5 | dependency: "direct dev"
6 | description:
7 | path: ".."
8 | relative: true
9 | source: path
10 | version: "0.2.0"
11 | async:
12 | dependency: transitive
13 | description:
14 | name: async
15 | url: "https://pub.flutter-io.cn"
16 | source: hosted
17 | version: "2.0.8"
18 | async_loader:
19 | dependency: "direct main"
20 | description:
21 | name: async_loader
22 | url: "https://pub.flutter-io.cn"
23 | source: hosted
24 | version: "0.1.2"
25 | boolean_selector:
26 | dependency: transitive
27 | description:
28 | name: boolean_selector
29 | url: "https://pub.flutter-io.cn"
30 | source: hosted
31 | version: "1.0.4"
32 | charcode:
33 | dependency: transitive
34 | description:
35 | name: charcode
36 | url: "https://pub.flutter-io.cn"
37 | source: hosted
38 | version: "1.1.2"
39 | collection:
40 | dependency: transitive
41 | description:
42 | name: collection
43 | url: "https://pub.flutter-io.cn"
44 | source: hosted
45 | version: "1.14.11"
46 | cupertino_icons:
47 | dependency: "direct main"
48 | description:
49 | name: cupertino_icons
50 | url: "https://pub.flutter-io.cn"
51 | source: hosted
52 | version: "0.1.2"
53 | easy_alert:
54 | dependency: "direct main"
55 | description:
56 | name: easy_alert
57 | url: "https://pub.flutter-io.cn"
58 | source: hosted
59 | version: "0.0.2"
60 | flutter:
61 | dependency: "direct main"
62 | description: flutter
63 | source: sdk
64 | version: "0.0.0"
65 | flutter_test:
66 | dependency: "direct dev"
67 | description: flutter
68 | source: sdk
69 | version: "0.0.0"
70 | matcher:
71 | dependency: transitive
72 | description:
73 | name: matcher
74 | url: "https://pub.flutter-io.cn"
75 | source: hosted
76 | version: "0.12.3+1"
77 | meta:
78 | dependency: transitive
79 | description:
80 | name: meta
81 | url: "https://pub.flutter-io.cn"
82 | source: hosted
83 | version: "1.1.6"
84 | path:
85 | dependency: transitive
86 | description:
87 | name: path
88 | url: "https://pub.flutter-io.cn"
89 | source: hosted
90 | version: "1.6.2"
91 | pedantic:
92 | dependency: transitive
93 | description:
94 | name: pedantic
95 | url: "https://pub.flutter-io.cn"
96 | source: hosted
97 | version: "1.4.0"
98 | quiver:
99 | dependency: transitive
100 | description:
101 | name: quiver
102 | url: "https://pub.flutter-io.cn"
103 | source: hosted
104 | version: "2.0.1"
105 | simple_permissions:
106 | dependency: "direct main"
107 | description:
108 | name: simple_permissions
109 | url: "https://pub.flutter-io.cn"
110 | source: hosted
111 | version: "0.1.9"
112 | sky_engine:
113 | dependency: transitive
114 | description: flutter
115 | source: sdk
116 | version: "0.0.99"
117 | source_span:
118 | dependency: transitive
119 | description:
120 | name: source_span
121 | url: "https://pub.flutter-io.cn"
122 | source: hosted
123 | version: "1.5.4"
124 | stack_trace:
125 | dependency: transitive
126 | description:
127 | name: stack_trace
128 | url: "https://pub.flutter-io.cn"
129 | source: hosted
130 | version: "1.9.3"
131 | stream_channel:
132 | dependency: transitive
133 | description:
134 | name: stream_channel
135 | url: "https://pub.flutter-io.cn"
136 | source: hosted
137 | version: "1.6.8"
138 | string_scanner:
139 | dependency: transitive
140 | description:
141 | name: string_scanner
142 | url: "https://pub.flutter-io.cn"
143 | source: hosted
144 | version: "1.0.4"
145 | term_glyph:
146 | dependency: transitive
147 | description:
148 | name: term_glyph
149 | url: "https://pub.flutter-io.cn"
150 | source: hosted
151 | version: "1.1.0"
152 | test_api:
153 | dependency: transitive
154 | description:
155 | name: test_api
156 | url: "https://pub.flutter-io.cn"
157 | source: hosted
158 | version: "0.2.2"
159 | typed_data:
160 | dependency: transitive
161 | description:
162 | name: typed_data
163 | url: "https://pub.flutter-io.cn"
164 | source: hosted
165 | version: "1.1.6"
166 | vector_math:
167 | dependency: transitive
168 | description:
169 | name: vector_math
170 | url: "https://pub.flutter-io.cn"
171 | source: hosted
172 | version: "2.0.8"
173 | sdks:
174 | dart: ">=2.1.0 <3.0.0"
175 | flutter: ">=0.1.4 <2.0.0"
176 |
--------------------------------------------------------------------------------
/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: amap_location_example
2 | description: Demonstrates how to use the amap_location plugin.
3 | publish_to: 'none'
4 |
5 | environment:
6 | sdk: ">=2.1.0 <3.0.0"
7 |
8 | dependencies:
9 | flutter:
10 | sdk: flutter
11 |
12 | # The following adds the Cupertino Icons font to your application.
13 | # Use with the CupertinoIcons class for iOS style icons.
14 | cupertino_icons: ^0.1.2
15 |
16 | async_loader:
17 | simple_permissions:
18 | easy_alert:
19 |
20 | dev_dependencies:
21 | flutter_test:
22 | sdk: flutter
23 |
24 | amap_location:
25 | path: ../
26 |
27 | # For information on the generic Dart part of this file, see the
28 | # following page: https://www.dartlang.org/tools/pub/pubspec
29 |
30 | # The following section is specific to Flutter.
31 | flutter:
32 |
33 | # The following line ensures that the Material Icons font is
34 | # included with your application, so that you can use the icons in
35 | # the material Icons class.
36 | uses-material-design: true
37 |
38 | # To add assets to your application, add an assets section, like this:
39 | # assets:
40 | # - images/a_dot_burr.jpeg
41 | # - images/a_dot_ham.jpeg
42 |
43 | # An image asset can refer to one or more resolution-specific "variants", see
44 | # https://flutter.io/assets-and-images/#resolution-aware.
45 |
46 | # For details regarding adding assets from package dependencies, see
47 | # https://flutter.io/assets-and-images/#from-packages
48 |
49 | # To add custom fonts to your application, add a fonts section here,
50 | # in this "flutter" section. Each entry in this list should have a
51 | # "family" key with the font family name, and a "fonts" key with a
52 | # list giving the asset and other descriptors for the font. For
53 | # example:
54 | # fonts:
55 | # - family: Schyler
56 | # fonts:
57 | # - asset: fonts/Schyler-Regular.ttf
58 | # - asset: fonts/Schyler-Italic.ttf
59 | # style: italic
60 | # - family: Trajan Pro
61 | # fonts:
62 | # - asset: fonts/TrajanPro.ttf
63 | # - asset: fonts/TrajanPro_Bold.ttf
64 | # weight: 700
65 | #
66 | # For details regarding fonts from package dependencies,
67 | # see https://flutter.io/custom-fonts/#from-packages
68 |
--------------------------------------------------------------------------------
/example/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility that Flutter provides. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter/material.dart';
9 | import 'package:flutter_test/flutter_test.dart';
10 |
11 | import 'package:amap_location_example/main.dart';
12 |
13 | void main() {
14 | testWidgets('Verify Platform version', (WidgetTester tester) async {
15 | // Build our app and trigger a frame.
16 | await tester.pumpWidget(MyApp());
17 |
18 | // Verify that platform version is retrieved.
19 | expect(
20 | find.byWidgetPredicate(
21 | (Widget widget) =>
22 | widget is Text && widget.data.startsWith('Running on:'),
23 | ),
24 | findsOneWidget,
25 | );
26 | });
27 | }
28 |
--------------------------------------------------------------------------------
/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/best-flutter/flutter_amap_location/ecd6f0763c2bbfd54889327200f2e1c499eb06a7/ios/Assets/.gitkeep
--------------------------------------------------------------------------------
/ios/Classes/AmapLocationPlugin.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @interface AmapLocationPlugin : NSObject
4 | @end
5 |
--------------------------------------------------------------------------------
/ios/Classes/AmapLocationPlugin.m:
--------------------------------------------------------------------------------
1 | #import "AmapLocationPlugin.h"
2 |
3 | #import
4 | #import
5 |
6 |
7 | /*
8 | static NSDictionary* DesiredAccuracy = @{@"kCLLocationAccuracyBest":@(kCLLocationAccuracyBest),
9 | @"kCLLocationAccuracyNearestTenMeters":@(kCLLocationAccuracyNearestTenMeters),
10 | @"kCLLocationAccuracyHundredMeters":@(kCLLocationAccuracyHundredMeters),
11 | @"kCLLocationAccuracyKilometer":@(kCLLocationAccuracyKilometer),
12 | @"kCLLocationAccuracyThreeKilometers":@(kCLLocationAccuracyThreeKilometers),
13 |
14 | };*/
15 |
16 |
17 | @interface AmapLocationPlugin()
18 |
19 | @property (nonatomic, retain) AMapLocationManager *locationManager;
20 | @property (nonatomic, copy) AMapLocatingCompletionBlock completionBlock;
21 | @property (nonatomic, weak) FlutterMethodChannel* channel;
22 |
23 | @end
24 |
25 | @implementation AmapLocationPlugin
26 |
27 | + (void)registerWithRegistrar:(NSObject*)registrar {
28 | FlutterMethodChannel* channel = [FlutterMethodChannel
29 | methodChannelWithName:@"amap_location"
30 | binaryMessenger:[registrar messenger]];
31 | AmapLocationPlugin* instance = [[AmapLocationPlugin alloc] init];
32 | instance.channel = channel;
33 | [registrar addMethodCallDelegate:instance channel:channel];
34 | }
35 |
36 |
37 |
38 | - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
39 | NSString* method = call.method;
40 |
41 | if ([@"startup" isEqualToString:method]) {
42 | //启动系统
43 | result(@([self startup:call.arguments]));
44 | }else if([@"shutdown" isEqualToString:method]){
45 | //关闭系统
46 | result(@([self shutdown]));
47 | }else if([@"getLocation" isEqualToString:method]){
48 | //进行单次定位请求
49 | [self getLocation: [call.arguments boolValue] result:result];
50 |
51 | }else if([@"stopLocation" isEqualToString:method]){
52 | //停止监听位置改变
53 | result(@([self stopLocation]));
54 | }else if([@"startLocation" isEqualToString:method]){
55 | //开始监听位置改变
56 | result(@([self startLocation]));
57 | }else if( [@"updateOption" isEqualToString:method] ){
58 |
59 | result(@([self updateOption:call.arguments]));
60 |
61 | }else if([@"setApiKey" isEqualToString:method]){
62 | [AMapServices sharedServices].apiKey = call.arguments;
63 |
64 | result(@YES);
65 | } else {
66 | result(FlutterMethodNotImplemented);
67 | }
68 | }
69 |
70 | -(double)getDesiredAccuracy:(NSString*)str{
71 |
72 | if([@"kCLLocationAccuracyBest" isEqualToString:str]){
73 | return kCLLocationAccuracyBest;
74 | }else if([@"kCLLocationAccuracyNearestTenMeters" isEqualToString:str]){
75 | return kCLLocationAccuracyNearestTenMeters;
76 | }else if([@"kCLLocationAccuracyHundredMeters" isEqualToString:str]){
77 | return kCLLocationAccuracyHundredMeters;
78 | }
79 | else if([@"kCLLocationAccuracyKilometer" isEqualToString:str]){
80 | return kCLLocationAccuracyKilometer;
81 | }
82 | else{
83 | return kCLLocationAccuracyThreeKilometers;
84 | }
85 |
86 |
87 | }
88 |
89 | -(BOOL)updateOption:(NSDictionary*)args{
90 | if(self.locationManager){
91 |
92 | //设置期望定位精度
93 | [self.locationManager setDesiredAccuracy:[ self getDesiredAccuracy: args[@"desiredAccuracy"]]];
94 |
95 | NSLog(@"%@",args);
96 |
97 | [self.locationManager setPausesLocationUpdatesAutomatically:[args[@"pausesLocationUpdatesAutomatically"] boolValue]];
98 |
99 | [self.locationManager setDistanceFilter: [args[@"distanceFilter"] doubleValue]];
100 |
101 | //设置在能不能再后台定位
102 | [self.locationManager setAllowsBackgroundLocationUpdates:[args[@"allowsBackgroundLocationUpdates"] boolValue]];
103 |
104 | //设置定位超时时间
105 | [self.locationManager setLocationTimeout:[args[@"locationTimeout"] integerValue]];
106 |
107 | //设置逆地理超时时间
108 | [self.locationManager setReGeocodeTimeout:[args[@"reGeocodeTimeout"] integerValue]];
109 |
110 | //定位是否需要逆地理信息
111 | [self.locationManager setLocatingWithReGeocode:[args[@"locatingWithReGeocode"] boolValue]];
112 |
113 | ///检测是否存在虚拟定位风险,默认为NO,不检测。 \n注意:设置为YES时,单次定位通过 AMapLocatingCompletionBlock 的error给出虚拟定位风险提示;连续定位通过 amapLocationManager:didFailWithError: 方法的error给出虚拟定位风险提示。error格式为error.domain==AMapLocationErrorDomain; error.code==AMapLocationErrorRiskOfFakeLocation;
114 | [self.locationManager setDetectRiskOfFakeLocation: [args[@"detectRiskOfFakeLocation"] boolValue ]];
115 |
116 | return YES;
117 |
118 | }
119 | return NO;
120 | }
121 |
122 | -(BOOL)startLocation{
123 | if(self.locationManager){
124 | [self.locationManager startUpdatingLocation];
125 | return YES;
126 | }
127 | return NO;
128 | }
129 |
130 | -(BOOL)stopLocation{
131 | if(self.locationManager){
132 | [self.locationManager stopUpdatingLocation];
133 | return YES;
134 | }
135 | return NO;
136 | }
137 |
138 | -(void)getLocation:(BOOL)withReGeocode result:(FlutterResult)result{
139 |
140 | self.completionBlock = ^(CLLocation *location, AMapLocationReGeocode *regeocode, NSError *error){
141 |
142 | if (error != nil && error.code == AMapLocationErrorLocateFailed)
143 | {
144 | //定位错误:此时location和regeocode没有返回值,不进行annotation的添加
145 | NSLog(@"定位错误:{%ld - %@};", (long)error.code, error.localizedDescription);
146 | result(@{ @"code":@(error.code),@"description":error.localizedDescription, @"success":@NO });
147 | return;
148 | }
149 | else if (error != nil
150 | && (error.code == AMapLocationErrorReGeocodeFailed
151 | || error.code == AMapLocationErrorTimeOut
152 | || error.code == AMapLocationErrorCannotFindHost
153 | || error.code == AMapLocationErrorBadURL
154 | || error.code == AMapLocationErrorNotConnectedToInternet
155 | || error.code == AMapLocationErrorCannotConnectToHost))
156 | {
157 | //逆地理错误:在带逆地理的单次定位中,逆地理过程可能发生错误,此时location有返回值,regeocode无返回值,进行annotation的添加
158 | NSLog(@"逆地理错误:{%ld - %@};", (long)error.code, error.localizedDescription);
159 | }
160 | else if (error != nil && error.code == AMapLocationErrorRiskOfFakeLocation)
161 | {
162 | //存在虚拟定位的风险:此时location和regeocode没有返回值,不进行annotation的添加
163 | NSLog(@"存在虚拟定位的风险:{%ld - %@};", (long)error.code, error.localizedDescription);
164 | result(@{ @"code":@(error.code),@"description":error.localizedDescription, @"success":@NO });
165 | return;
166 | }
167 | else
168 | {
169 | //没有错误:location有返回值,regeocode是否有返回值取决于是否进行逆地理操作,进行annotation的添加
170 | }
171 |
172 | NSMutableDictionary* md = [[NSMutableDictionary alloc]initWithDictionary: [AmapLocationPlugin location2map:location] ];
173 | if (regeocode)
174 | {
175 | [md addEntriesFromDictionary:[AmapLocationPlugin regeocode2map:regeocode]];
176 | md[@"code"] = @0;
177 | md[@"success"] = @YES;
178 | }
179 | else
180 | {
181 | md[@"code"]=@(error.code);
182 | md[@"description"]=error.localizedDescription;
183 | md[@"success"] = @YES;
184 | }
185 |
186 | result(md);
187 |
188 | };
189 | [self.locationManager requestLocationWithReGeocode:withReGeocode completionBlock:self.completionBlock];
190 |
191 | // [self.locationManager startUpdatingLocation];
192 | }
193 |
194 |
195 | +(id)checkNull:(NSObject*)value{
196 | return value == nil ? [NSNull null] : value;
197 | }
198 |
199 | +(NSDictionary*)regeocode2map:(AMapLocationReGeocode *)regeocode{
200 | return @{@"formattedAddress":regeocode.formattedAddress,
201 | @"country":regeocode.country,
202 | @"province":regeocode.province,
203 | @"city":regeocode.city,
204 | @"district":regeocode.district,
205 | @"citycode":regeocode.citycode,
206 | @"adcode":regeocode.adcode,
207 | @"street":regeocode.street,
208 | @"number":regeocode.number,
209 | @"POIName":[self checkNull : regeocode.POIName],
210 | @"AOIName":[self checkNull :regeocode.AOIName],
211 | };
212 | }
213 |
214 | +(NSDictionary*)location2map:(CLLocation *)location{
215 |
216 | return @{@"latitude": @(location.coordinate.latitude),
217 | @"longitude": @(location.coordinate.longitude),
218 | @"accuracy": @((location.horizontalAccuracy + location.verticalAccuracy)/2),
219 | @"altitude": @(location.altitude),
220 | @"speed": @(location.speed),
221 | @"timestamp": @(location.timestamp.timeIntervalSince1970),};
222 |
223 | }
224 |
225 |
226 | -(BOOL)startup:(NSDictionary*)args{
227 | if(self.locationManager)return NO;
228 |
229 | self.locationManager = [[AMapLocationManager alloc] init];
230 |
231 | [self.locationManager setDelegate:self];
232 |
233 | return [self updateOption:args];
234 | }
235 |
236 |
237 | -(BOOL)shutdown{
238 | if(self.locationManager){
239 | //停止定位
240 | [self.locationManager stopUpdatingLocation];
241 | [self.locationManager setDelegate:nil];
242 | self.locationManager = nil;
243 |
244 | return YES;
245 | }
246 | return NO;
247 |
248 | }
249 | /**
250 | * @brief 连续定位回调函数.注意:如果实现了本方法,则定位信息不会通过amapLocationManager:didUpdateLocation:方法回调。
251 | * @param manager 定位 AMapLocationManager 类。
252 | * @param location 定位结果。
253 | * @param reGeocode 逆地理信息。
254 | */
255 | - (void)amapLocationManager:(AMapLocationManager *)manager didUpdateLocation:(CLLocation *)location reGeocode:(AMapLocationReGeocode *)reGeocode{
256 |
257 | NSMutableDictionary* md = [[NSMutableDictionary alloc]initWithDictionary: [AmapLocationPlugin location2map:location] ];
258 | if(reGeocode){
259 | [md addEntriesFromDictionary:[ AmapLocationPlugin regeocode2map:reGeocode ]];
260 | }
261 |
262 | md[@"success"]=@YES;
263 |
264 | [self.channel invokeMethod:@"updateLocation" arguments:md];
265 |
266 | }
267 |
268 |
269 |
270 | /**
271 | * @brief 定位权限状态改变时回调函数
272 | * @param manager 定位 AMapLocationManager 类。
273 | * @param status 定位权限状态。
274 | */
275 | - (void)amapLocationManager:(AMapLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status{
276 |
277 | }
278 |
279 |
280 | /**
281 | * @brief 当定位发生错误时,会调用代理的此方法。
282 | * @param manager 定位 AMapLocationManager 类。
283 | * @param error 返回的错误,参考 CLError 。
284 | */
285 | - (void)amapLocationManager:(AMapLocationManager *)manager didFailWithError:(NSError *)error{
286 |
287 | NSLog(@"定位错误:{%ld - %@};", (long)error.code, error.localizedDescription);
288 |
289 |
290 |
291 | [self.channel invokeMethod:@"updateLocation" arguments:@{ @"code":@(error.code),@"description":error.localizedDescription,@"success":@NO }];
292 |
293 |
294 |
295 |
296 | }
297 | @end
298 |
--------------------------------------------------------------------------------
/ios/amap_location.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'
6 | s.version = '0.0.1'
7 | s.summary = 'A Flutter plugin to use amap location.高德地图定位组件'
8 | s.description = <<-DESC
9 | A Flutter plugin to use amap location.高德地图定位组件
10 | DESC
11 | s.homepage = 'http://example.com'
12 | s.license = { :file => '../LICENSE' }
13 | s.author = { 'JZoom' => 'jzoom8112@gmail.com' }
14 | s.source = { :path => '.' }
15 | s.source_files = 'Classes/**/*'
16 | s.public_header_files = 'Classes/**/*.h'
17 | s.dependency 'Flutter'
18 | s.dependency 'AMapLocation'
19 | s.static_framework = true
20 | s.ios.deployment_target = '8.0'
21 | end
22 |
23 |
--------------------------------------------------------------------------------
/lib/amap_location.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 |
3 | export 'amap_location_option.dart';
4 |
5 | import 'package:flutter/services.dart';
6 | import 'amap_location_option.dart';
7 |
8 | class AMapLocationQualityReport {
9 | static const int ok = 0;
10 | static const int noGpsProvider = 1;
11 | static const int off = 2;
12 | static const int modeSaving = 3;
13 | static const int noGpsPermission = 4;
14 |
15 | final bool wifiAble;
16 |
17 | final int gpsStatus;
18 |
19 | final int gpsSatellites;
20 |
21 | final String networkType;
22 |
23 | //整数部分为秒,浮点部分为毫秒
24 | final double netUseTime;
25 |
26 | final String adviseMessage;
27 |
28 | AMapLocationQualityReport({
29 | this.wifiAble,
30 | this.gpsSatellites,
31 | this.gpsStatus,
32 | this.adviseMessage,
33 | this.netUseTime,
34 | this.networkType,
35 | });
36 | }
37 |
38 | class AMapLocation {
39 | final double accuracy;
40 | final double altitude;
41 | final double speed;
42 | final double timestamp;
43 | final double latitude;
44 | final double longitude;
45 |
46 | final String formattedAddress;
47 | final String country;
48 | final String province;
49 | final String city;
50 | final String district;
51 | final String citycode;
52 | final String adcode;
53 | final String street;
54 | final String number;
55 | final String POIName;
56 | final String AOIName;
57 |
58 | // 这个参数很重要,在anroid和ios下的判断标准不一样
59 | // android下: 0 定位成功。
60 | // 1 一些重要参数为空,如context;请对定位传递的参数进行非空判断。
61 | // 2 定位失败,由于仅扫描到单个wifi,且没有基站信息。
62 | // 3 获取到的请求参数为空,可能获取过程中出现异常。
63 | // 4 请求服务器过程中的异常,多为网络情况差,链路不通导致,请检查设备网络是否通畅。
64 | // 5 返回的XML格式错误,解析失败。
65 | // 6 定位服务返回定位失败,如果出现该异常,请将errorDetail信息通过API@autonavi.com反馈给我们。
66 | // 7 KEY建权失败,请仔细检查key绑定的sha1值与apk签名sha1值是否对应。
67 | // 8 Android exception通用错误,请将errordetail信息通过API@autonavi.com反馈给我们。
68 | // 9 定位初始化时出现异常,请重新启动定位。
69 | // 10 定位客户端启动失败,请检查AndroidManifest.xml文件是否配置了APSService定位服务
70 | // 11 定位时的基站信息错误,请检查是否安装SIM卡,设备很有可能连入了伪基站网络。
71 | // 12 缺少定位权限,请在设备的设置中开启app的定位权限。
72 | //
73 | // ios下:
74 | // typedef NS_ENUM(NSInteger, AMapLocationErrorCode)
75 | // {
76 | // AMapLocationErrorUnknown = 1, ///<未知错误
77 | // AMapLocationErrorLocateFailed = 2, ///<定位错误
78 | // AMapLocationErrorReGeocodeFailed = 3, ///<逆地理错误
79 | // AMapLocationErrorTimeOut = 4, ///<超时
80 | // AMapLocationErrorCanceled = 5, ///<取消
81 | // AMapLocationErrorCannotFindHost = 6, ///<找不到主机
82 | // AMapLocationErrorBadURL = 7, /// 0 ,有可能是逆地理位置有错误,那么这个时候仍然是成功的
155 | return success;
156 | }
157 |
158 | /// 是否有详细地址
159 | bool hasAddress() {
160 | return formattedAddress != null;
161 | }
162 | }
163 |
164 | class AMapLocationClient {
165 | static const MethodChannel _channel = const MethodChannel('amap_location');
166 |
167 | static StreamController _locationUpdateStreamController =
168 | new StreamController.broadcast();
169 |
170 | /// 定位改变监听
171 | static Stream get onLocationUpate =>
172 | _locationUpdateStreamController.stream;
173 |
174 | /// 设置ios的key,android可以直接在配置文件中设置
175 | static Future setApiKey(String key) async {
176 | return await _channel.invokeMethod("setApiKey", key);
177 | }
178 |
179 | /// 直接获取到定位,不必先启用监听
180 | /// @param needsAddress 是否需要详细地址信息
181 | static Future getLocation(bool needsAddress) async {
182 | final dynamic location =
183 | await _channel.invokeMethod('getLocation', needsAddress);
184 | return AMapLocation.fromMap(location);
185 | }
186 |
187 | /// 启动系统
188 | /// @param options 启动系统所需选项
189 | static Future startup(AMapLocationOption option) async {
190 | _channel.setMethodCallHandler(handler);
191 | return await _channel.invokeMethod("startup", option.toMap());
192 | }
193 |
194 | /// 更新选项,如果已经在监听,那么要先停止监听,再调用这个函数
195 | static Future updateOption(AMapLocationOption option) async {
196 | return await _channel.invokeMethod("updateOption", option);
197 | }
198 |
199 | static Future shutdown() async {
200 | return await _channel.invokeMethod("shutdown");
201 | }
202 |
203 | /// 启动监听位置改变
204 | static Future startLocation() async {
205 | return await _channel.invokeMethod("startLocation");
206 | }
207 |
208 | /// 停止监听位置改变
209 | static Future stopLocation() async {
210 | return await _channel.invokeMethod("stopLocation");
211 | }
212 |
213 | static Future handler(MethodCall call) {
214 | String method = call.method;
215 |
216 | switch (method) {
217 | case "updateLocation":
218 | {
219 | Map args = call.arguments;
220 | _locationUpdateStreamController.add(AMapLocation.fromMap(args));
221 | }
222 | break;
223 | }
224 | return new Future.value("");
225 | }
226 | }
227 |
--------------------------------------------------------------------------------
/lib/amap_location_option.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | /// android网络传输http还是https协议
4 | enum AMapLocationProtocol { HTTP, HTTPS }
5 |
6 | /// android 逆地理位置信息的语言
7 | enum GeoLanguage { DEFAULT, ZH, EN }
8 |
9 | /// android 定位模式
10 | enum AMapLocationMode { Battery_Saving, Device_Sensors, Hight_Accuracy }
11 |
12 | /// ios定位精度
13 | enum CLLocationAccuracy {
14 | kCLLocationAccuracyBest,
15 | kCLLocationAccuracyNearestTenMeters,
16 | kCLLocationAccuracyHundredMeters,
17 | kCLLocationAccuracyKilometer,
18 | kCLLocationAccuracyThreeKilometers
19 | }
20 |
21 | class AMapLocationOption {
22 | ////////////////////////////////////////////////////////////
23 | /// 以下属性为android特有
24 | ////////////////////////////////////////////////////////////
25 |
26 | //可选,设置定位模式,可选的模式有高精度、仅设备、仅网络。默认为高精度模式
27 | final AMapLocationMode locationMode;
28 |
29 | //可选,设置是否gps优先,只在高精度模式下有效。默认关闭
30 | final bool gpsFirst;
31 |
32 | //可选,设置网络请求超时时间(ms)。默认为30秒。在仅设备模式下无效
33 | final int httpTimeOut;
34 |
35 | //可选,设置定位间隔(ms)。默认为2秒
36 | final int interval;
37 |
38 | //可选,设置是否返回逆地理地址信息。默认是true
39 | final bool needsAddress;
40 |
41 | //可选,设置是否单次定位。默认是false
42 | final bool onceLocation;
43 |
44 | //可选,设置是否等待wifi刷新,默认为false.如果设置为true,会自动变为单次定位,持续定位时不要使用
45 | final bool onceLocationLatest;
46 |
47 | //可选, 设置网络请求的协议。可选HTTP或者HTTPS。默认为HTTP
48 | final AMapLocationProtocol locationProtocal;
49 |
50 | //可选,设置是否使用传感器。默认是false
51 | final bool sensorEnable;
52 |
53 | //可选,设置是否开启wifi扫描。默认为true,如果设置为false会同时停止主动刷新,停止以后完全依赖于系统刷新,定位位置可能存在误差
54 | final bool wifiScan;
55 |
56 | //可选,设置是否使用缓存定位,默认为true
57 | final bool locationCacheEnable;
58 |
59 | ////////////////////////////////////////////////////////////
60 | ///以下属性为ios特有
61 | ////////////////////////////////////////////////////////////
62 | ///设定期望的定位精度。单位米,默认为 kCLLocationAccuracyBest。
63 | ///定位服务会尽可能去获取满足desiredAccuracy的定位结果,但不保证一定会得到满足期望的结果。
64 | ///\n注意:设置为kCLLocationAccuracyBest或kCLLocationAccuracyBestForNavigation时,
65 | ///单次定位会在达到locationTimeout设定的时间后,将时间内获取到的最高精度的定位结果返回。
66 | final CLLocationAccuracy desiredAccuracy;
67 |
68 | ///指定定位是否会被系统自动暂停。默认为NO。
69 | final bool pausesLocationUpdatesAutomatically;
70 |
71 | ///是否允许后台定位。默认为NO。只在iOS 9.0及之后起作用。设置为YES的时候必须保证
72 | /// Background Modes 中的 Location updates 处于选中状态,否则会抛出异常。
73 | /// 由于iOS系统限制,需要在定位未开始之前或定位停止之后,修改该属性的值才会有效果。
74 | final bool allowsBackgroundLocationUpdates;
75 |
76 | ///指定单次定位超时时间,默认为10s。最小值是2s。
77 | /// 注意单次定位请求前设置。
78 | /// 注意: 单次定位超时时间从确定了定位权限(非kCLAuthorizationStatusNotDetermined状态)后开始计算。
79 | final int locationTimeout;
80 |
81 | ///指定单次定位逆地理超时时间,默认为5s。最小值是2s。注意单次定位请求前设置。
82 | final int reGeocodeTimeout;
83 |
84 | ///连续定位是否返回逆地理信息,默认NO。
85 | final bool locatingWithReGeocode;
86 |
87 | ///检测是否存在虚拟定位风险,默认为NO,不检测。
88 | /// \n注意:设置为YES时,单次定位通过 AMapLocatingCompletionBlock 的
89 | /// error给出虚拟定位风险提示;
90 | /// 连续定位通过 amapLocationManager:didFailWithError: 方法的
91 | /// error给出虚拟定位风险提示。
92 | /// error格式为error.domain==AMapLocationErrorDomain;
93 | /// error.code==AMapLocationErrorRiskOfFakeLocation;
94 | final bool detectRiskOfFakeLocation;
95 |
96 | ///设定定位的最小更新距离。单位米,默认为 kCLDistanceFilterNone,表示只要检测到设备位置发生变化就会更新位置信息。
97 | final double distanceFilter;
98 |
99 | static final double kCLDistanceFilterNone = -1.0;
100 |
101 | ////////////////////////////////////////////////////////////
102 | /// 以下为通用属性
103 | ////////////////////////////////////////////////////////////
104 | //可选,设置逆地理信息的语言,默认值为默认语言(根据所在地区选择语言)
105 | final GeoLanguage geoLanguage;
106 |
107 | AMapLocationOption({
108 | this.locationMode: AMapLocationMode.Hight_Accuracy,
109 | this.gpsFirst: false,
110 | this.httpTimeOut: 10000, //30有点长,特殊情况才需要这么长,改成10
111 | this.interval: 2000,
112 | this.needsAddress: true,
113 | this.onceLocation: false,
114 | this.onceLocationLatest: false,
115 | this.locationProtocal: AMapLocationProtocol.HTTP,
116 | this.sensorEnable: false,
117 | this.wifiScan: true,
118 | this.locationCacheEnable: true,
119 | this.allowsBackgroundLocationUpdates: false,
120 | this.desiredAccuracy:
121 | CLLocationAccuracy.kCLLocationAccuracyBest, //精度越高,时间越久
122 | this.locatingWithReGeocode: false,
123 | this.locationTimeout: 5, //注意这里的单位为秒
124 | this.pausesLocationUpdatesAutomatically: false,
125 | this.reGeocodeTimeout: 5, //注意ios的时间单位是秒
126 | this.detectRiskOfFakeLocation: false,
127 | this.distanceFilter: -1.0,
128 | this.geoLanguage: GeoLanguage.DEFAULT,
129 | });
130 |
131 | String getLocationProtocal() {
132 | return locationProtocal == AMapLocationProtocol.HTTP ? "HTTP" : "HTTPS";
133 | }
134 |
135 | String getGeoLanguage() {
136 | switch (geoLanguage) {
137 | case GeoLanguage.DEFAULT:
138 | return "DEFAULT";
139 | case GeoLanguage.EN:
140 | return "EN";
141 | case GeoLanguage.ZH:
142 | return "ZH";
143 | default:
144 | return "unknown";
145 | }
146 | }
147 |
148 | String getLocationMode() {
149 | switch (locationMode) {
150 | case AMapLocationMode.Hight_Accuracy:
151 | return "Hight_Accuracy";
152 | case AMapLocationMode.Battery_Saving:
153 | return "Battery_Saving";
154 | case AMapLocationMode.Device_Sensors:
155 | return "Device_Sensors";
156 | default:
157 | return "unknown";
158 | }
159 | }
160 |
161 | String getDesiredAccuracy() {
162 | switch (desiredAccuracy) {
163 | case CLLocationAccuracy.kCLLocationAccuracyBest:
164 | return "kCLLocationAccuracyBest";
165 | case CLLocationAccuracy.kCLLocationAccuracyHundredMeters:
166 | return "kCLLocationAccuracyHundredMeters";
167 | case CLLocationAccuracy.kCLLocationAccuracyKilometer:
168 | return "kCLLocationAccuracyKilometer";
169 | case CLLocationAccuracy.kCLLocationAccuracyNearestTenMeters:
170 | return "kCLLocationAccuracyNearestTenMeters";
171 | case CLLocationAccuracy.kCLLocationAccuracyThreeKilometers:
172 | return "kCLLocationAccuracyThreeKilometers";
173 | default:
174 | return "unknown";
175 | }
176 | }
177 |
178 | Map toMap() {
179 | if (Platform.isAndroid) {
180 | return {
181 | "locationMode": getLocationMode(),
182 | "gpsFirst": gpsFirst,
183 | "httpTimeOut": httpTimeOut,
184 | "interval": interval,
185 | "needsAddress": needsAddress,
186 | "onceLocation": onceLocation,
187 | "onceLocationLatest": onceLocationLatest,
188 | "locationProtocal": getLocationProtocal(),
189 | "sensorEnable": sensorEnable,
190 | "wifiScan": wifiScan,
191 | "locationCacheEnable": locationCacheEnable,
192 | "geoLanguage": getGeoLanguage()
193 | };
194 | } else {
195 | return {
196 | "allowsBackgroundLocationUpdates": allowsBackgroundLocationUpdates,
197 | "desiredAccuracy": getDesiredAccuracy(),
198 | "locatingWithReGeocode": locatingWithReGeocode,
199 | "locationTimeout": locationTimeout,
200 | "pausesLocationUpdatesAutomatically":
201 | pausesLocationUpdatesAutomatically,
202 | "reGeocodeTimeout": reGeocodeTimeout,
203 | "detectRiskOfFakeLocation": detectRiskOfFakeLocation,
204 | "distanceFilter": distanceFilter,
205 | "geoLanguage": getGeoLanguage()
206 | };
207 | }
208 | }
209 | }
210 |
--------------------------------------------------------------------------------
/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://www.dartlang.org/tools/pub/glossary#lockfile
3 | packages:
4 | async:
5 | dependency: transitive
6 | description:
7 | name: async
8 | url: "https://pub.flutter-io.cn"
9 | source: hosted
10 | version: "2.0.8"
11 | boolean_selector:
12 | dependency: transitive
13 | description:
14 | name: boolean_selector
15 | url: "https://pub.flutter-io.cn"
16 | source: hosted
17 | version: "1.0.4"
18 | charcode:
19 | dependency: transitive
20 | description:
21 | name: charcode
22 | url: "https://pub.flutter-io.cn"
23 | source: hosted
24 | version: "1.1.2"
25 | collection:
26 | dependency: transitive
27 | description:
28 | name: collection
29 | url: "https://pub.flutter-io.cn"
30 | source: hosted
31 | version: "1.14.11"
32 | flutter:
33 | dependency: "direct main"
34 | description: flutter
35 | source: sdk
36 | version: "0.0.0"
37 | flutter_test:
38 | dependency: "direct dev"
39 | description: flutter
40 | source: sdk
41 | version: "0.0.0"
42 | matcher:
43 | dependency: transitive
44 | description:
45 | name: matcher
46 | url: "https://pub.flutter-io.cn"
47 | source: hosted
48 | version: "0.12.3+1"
49 | meta:
50 | dependency: transitive
51 | description:
52 | name: meta
53 | url: "https://pub.flutter-io.cn"
54 | source: hosted
55 | version: "1.1.6"
56 | path:
57 | dependency: transitive
58 | description:
59 | name: path
60 | url: "https://pub.flutter-io.cn"
61 | source: hosted
62 | version: "1.6.2"
63 | pedantic:
64 | dependency: transitive
65 | description:
66 | name: pedantic
67 | url: "https://pub.flutter-io.cn"
68 | source: hosted
69 | version: "1.4.0"
70 | quiver:
71 | dependency: transitive
72 | description:
73 | name: quiver
74 | url: "https://pub.flutter-io.cn"
75 | source: hosted
76 | version: "2.0.1"
77 | sky_engine:
78 | dependency: transitive
79 | description: flutter
80 | source: sdk
81 | version: "0.0.99"
82 | source_span:
83 | dependency: transitive
84 | description:
85 | name: source_span
86 | url: "https://pub.flutter-io.cn"
87 | source: hosted
88 | version: "1.5.4"
89 | stack_trace:
90 | dependency: transitive
91 | description:
92 | name: stack_trace
93 | url: "https://pub.flutter-io.cn"
94 | source: hosted
95 | version: "1.9.3"
96 | stream_channel:
97 | dependency: transitive
98 | description:
99 | name: stream_channel
100 | url: "https://pub.flutter-io.cn"
101 | source: hosted
102 | version: "1.6.8"
103 | string_scanner:
104 | dependency: transitive
105 | description:
106 | name: string_scanner
107 | url: "https://pub.flutter-io.cn"
108 | source: hosted
109 | version: "1.0.4"
110 | term_glyph:
111 | dependency: transitive
112 | description:
113 | name: term_glyph
114 | url: "https://pub.flutter-io.cn"
115 | source: hosted
116 | version: "1.1.0"
117 | test_api:
118 | dependency: transitive
119 | description:
120 | name: test_api
121 | url: "https://pub.flutter-io.cn"
122 | source: hosted
123 | version: "0.2.2"
124 | typed_data:
125 | dependency: transitive
126 | description:
127 | name: typed_data
128 | url: "https://pub.flutter-io.cn"
129 | source: hosted
130 | version: "1.1.6"
131 | vector_math:
132 | dependency: transitive
133 | description:
134 | name: vector_math
135 | url: "https://pub.flutter-io.cn"
136 | source: hosted
137 | version: "2.0.8"
138 | sdks:
139 | dart: ">=2.1.0 <3.0.0"
140 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: amap_location
2 | description: AMap location plugin for flutter.高德地图定位插件
3 | version: 0.2.0
4 | author: JZoom
5 | homepage: https://github.com/best-flutter/flutter_amap_location
6 |
7 | environment:
8 | sdk: ">=2.1.0 <3.0.0"
9 |
10 | dependencies:
11 | flutter:
12 | sdk: flutter
13 |
14 | dev_dependencies:
15 | flutter_test:
16 | sdk: flutter
17 |
18 | flutter:
19 | plugin:
20 | androidPackage: com.jzoom.amaplocation
21 | pluginClass: AmapLocationPlugin
22 |
--------------------------------------------------------------------------------
/test/amap_location_test.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/services.dart';
2 | import 'package:flutter_test/flutter_test.dart';
3 | import 'package:amap_location/amap_location.dart';
4 |
5 | void main() {
6 | const MethodChannel channel = MethodChannel('amap_location');
7 |
8 | setUp(() {
9 | channel.setMockMethodCallHandler((MethodCall methodCall) async {
10 | return '42';
11 | });
12 | });
13 |
14 | tearDown(() {
15 | channel.setMockMethodCallHandler(null);
16 | });
17 |
18 | test('getPlatformVersion', () async {
19 | expect(await AMapLocationClient.getLocation(true), '42');
20 | });
21 | }
22 |
--------------------------------------------------------------------------------