地图sdk集成时的注意事项

权限

这里使用的是高德sdk

需要在info.plist中配置键值


info.png

否则会提示权限问题:

2016-11-09 19:07:31.669 WBX[46561:12863819] This app has attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSLocationAlwaysUsageDescription key with a string value explaining to the user how the app uses this data

2016-11-09 19:07:31.672 WBX[46561:12863819] This app has attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSLocationWhenInUseUsageDescription key with a string value explaining to the user how the app uses this data

调试

由于在模拟器上不能使用GPS,但在调试的时候,可以使用模拟地址


adress.png

再加上设置userTrackingMode就可以模拟调试定位地址了

// 跟踪用户的位置 - 可以将用户定位在地图的中心,并且放大地图,有的时候,速度会有些慢!
_mapView.userTrackingMode = MAUserTrackingModeFollow;

允许后台运行

允许地图在用户退到主屏/锁屏时还能运行不被暂停需要设置两个地方:

  1. 开启后台&取消暂停更新
    // 允许后台定位 - 保证 Background Modes 中的 Location updates 处于选中状态
    _mapView.allowsBackgroundLocationUpdates = YES;
    
    //  不允许系统暂停位置更新
    _mapView.pausesLocationUpdatesAutomatically = NO;
  1. 设置项目的location updates


    loca.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 174,554评论 25 709
  • 出自http://my.oschina.net/are1OfBlog/blog/420034 摘要 现在很多社交、...
    JJO阅读 4,199评论 4 19
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,259评论 19 139
  • 怀揣着不一样的梦想,就要付出不一样的努力 有的人努力打游戏 有的人努力出去玩 有的人努力去学习 有的人努力做科研 ...
    梦花生阅读 201评论 1 5
  • 大鹏丶阅读 328评论 0 1