地图sdk集成时的注意事项

权限

这里使用的是高德sdk

需要在info.plist中配置键值


地图sdk集成时的注意事项_第1张图片
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,但在调试的时候,可以使用模拟地址


地图sdk集成时的注意事项_第2张图片
adress.png

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

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

允许后台运行

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

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


    地图sdk集成时的注意事项_第3张图片
    loca.png

你可能感兴趣的:(地图sdk集成时的注意事项)