【Flutter】集成高德地图

Android:


    
    
    
    
    
    
    
    
    
    
    
    


    ...
    

在应用级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使用。

  1. 别忘记在xcode中Info.plist添加NSLocationAlwaysAndWhenInUseUsageDeionNSLocationAlwaysUsageDeionNSLocationWhenInUseUsageDeionNSLocationAlwaysAndWhenInUseUsageDescriptionNSLocationWhenInUseUsageDescription权限,具体可参考:
    https://blog.csdn.net/u011154007/article/details/52915566
  2. 配置后台定位权限,打开xcode runner 》 targets 》 runner 》 capabilities 》 background modes 》 勾选 location updates。
  3. 设置模拟器坐标, xcode 》 模拟器(simuator) 》 dubug 》 location 》 custon location。
  4. 修改apple clang – language的compile soures as: objective-c++。
  5. 在info.plist中中文件新增一行io.flutter.embedded_views_previewtrue。参考嵌入支持的iOS视图已经降落在主
  • https://lbs.amap.com/api/ios-sdk/guide/create-project/get-key/
  • https://www.cnblogs.com/niceyoo/p/11095938.html
  • https://github.com/OpenFlutter/amap_base_flutter

你可能感兴趣的:(【Flutter】集成高德地图)