Android:
...
android:name="com.amap.api.v2.apikey"
android:value="您的Key"/>
在应用级build.gradie内的dependencies导入implementation “com.amap.api:location:latest.integration”。
配置defaultContig multiDexEnabled ture。
Ios:
在配置ios环境之前,你需要在项目执行:cd ios , pod install安装依赖
由于与andorid不同,iOS端设置的key在实例之中:
await AMap.init('您的key'); // 这个方法在Android端无效
AmapLocation().getLocation(LocationClientOptions(
isOncelLocation: true
)).then((res) {
print(res);
});
由于amap-base-flutter二端实现的方式不同,因此你需要将amap封装成独立包,扩展统一的api使用。
别忘记在xcode中Info.plist添加NSLocationAlwaysAndWhenInUseUsageDeion、NSLocationAlwaysUsageDeion 、NSLocationWhenInUseUsageDeion、NSLocationAlwaysAndWhenInUseUsageDescription、NSLocationWhenInUseUsageDescription权限,具体可参考:
https://blog.csdn.net/u011154007/article/details/52915566
配置后台定位权限,打开xcode runner 》 targets 》 runner 》 capabilities 》 background modes 》 勾选 location updates。
设置模拟器坐标, xcode 》 模拟器(simuator) 》 dubug 》 location 》 custon location。
修改apple clang – language的compile soures as: objective-c++。
在info.plist中中文件新增一行io.flutter.embedded_views_preview为true。参考嵌入支持的iOS视图已经降落在主