全部服务产品
开发者频道
定价
登录
步骑行后台投屏
下载开发文档
BMKBackgroundMapView使用流程
1. 创建后台地图视图BMKBackgroundMapView
#import <BaiduMapAPI_Map/BMKMapComponent.h>
// 创建BMKBackgroundMapView
_backgroundMapView = [BMKBackgroundMapView new];
// 设置_backgroundMapView的frame
self.backgroundMapView.frame = CGRectMake(0, 150, self.view.frame.size.width, 700);
2. 关联BMKMapView,用于底图路网数据绑定同步
// 1.获取多实例地图的BMKMapView
BMKMapView *mapView = [self.multiNaviView getNaviMapView]
//2.BMKMapView设置支持后台绘制
[mapView setSupportBackgroundDraw:YES];
//3.关联到BMKBackgroundMapView
self.backgroundMapView.mapview = mapView;
3. 关联BMKBackgroundNavigationView,用于导航中路线,实时信息等数据绑定同步
// 从导航组建从获取BMKBackgroundNavigationView,并关联到BMKBackgroundMapView
self.backgroundMapView.navigationView = [[BMKCycleNavigationManager sharedManager] getBackgroundNavigationView];
4. 添加到父View
[self.view addSubview:self.backgroundMapView];
5. 退到后台后开启后台地图绘制
// 建议监听系统进出前后台通知,控制绘制开始/停止
[self.backgroundMapView startRender];
[self.backgroundMapView stopRender];
BMKBackgroundMapView可配置参数
1. 帧率控制
/// 帧率控制,默认30帧/s,范围10~60帧/s
@property (nonatomic, assign) NSInteger frameRate;
2. 3D绘制控制
/// 3D绘制
@property (nonatomic, assign) BOOL enable3D;
3. 关闭/开启渲染控制
/// 开始渲染
- (void)startRender;
/// 结束渲染
- (void)stopRender;
4. 自定义背景色
/// 获取背景图层,用于自定义背景颜色,设置UIView的backgroundColor即可
@property (nonatomic, readonly) UIView *backgroundView;
5. 路网相关自定义
/// 获取路网图层,用于自定义路网颜色
@property (nonatomic, readonly) BMKBackgroundRoadNetView *roadNetView;

5.1 自定义路网颜色

/// 设置路网颜色
@property (nonatomic, strong) UIColor *roadNetColor;
6. 导航元素相关
/// 获取导航图层,用于自定义导航路线宽度,颜色(驾车导航路线路况颜色,走过置灰或擦除,置灰颜色),路线数据更新;
/// 用于自定义导航小车图标及大小,位置方向更新,罗盘是否显示,小车车头是否跟随手机旋转
@property (nonatomic, strong) BMKBackgroundNavigationView *navigationView;

6.1 相关属性

/// 是否支持绘制引导线(当前位置偏离路线时),默认NO
@property (nonatomic, assign) BOOL needDrawGuideLine;
/// 是否支持绘制引导线(当前位置偏离路线时),默认蓝色虚线
@property (nonatomic, strong) UIColor *guideLineColor;
/// 是否支持绘制引导线(当前位置偏离路线时),默认2point,范围1~30point
@property (nonatomic, assign) CGFloat guideLineWidth;
/// 设置是否绘制起点图标
@property (nonatomic, assign) BOOL needDrawStartPoint;
/// 设置起点经纬度位置
@property (nonatomic, assign) CLLocationCoordinate2D startPoint;
/// 设置起点图标
@property (nonatomic, strong, nullable) UIImage *startPointIcon;
/// 设置起点图标尺寸,默认图片尺寸
@property (nonatomic, assign) CGSize startPointIconSize;
/// 设置起点图标偏移量,默认图片底部中心在经纬度位置(0.0,-0.5),X轴负数向左,Y轴负数向上片,范围值-0.5~0.5
@property (nonatomic, assign) CGPoint startPointIconOffset;
/// 设置是否绘制途径点图标
@property (nonatomic, assign) BOOL needDrawViaPoint;
/// 设置已走过途径点绘制模式
@property (nonatomic, assign) BMKViaPointPassedDisplayMode viaPointPassedDisplayMode;
/// 设置途径点经纬度位置列表
@property (nonatomic, copy, nullable) NSArray<BMKNaviViaPointInfo *> *viaPoints;
/// 设置途径点图标
@property (nonatomic, strong, nullable) UIImage *viaPointIcon;
/// 设置已走过途径点图标
@property (nonatomic, strong, nullable) UIImage *viaPassedPointIcon;
/// 设置途径点图标尺寸,默认图片尺寸
@property (nonatomic, assign) CGSize viaPointIconSize;
/// 设置途径点图标偏移量,默认图片底部中心在经纬度位置(0.0,-0.5),X轴负数向左,Y轴负数向上片,范围值-0.5~0.5
@property (nonatomic, assign) CGPoint viaPointIconOffset;
/// 设置是否绘制终点图标
@property (nonatomic, assign) BOOL needDrawEndPoint;
/// 设置终点经纬度位置
@property (nonatomic, assign) CLLocationCoordinate2D endPoint;
/// 设置终点图标
@property (nonatomic, strong, nullable) UIImage *endPointIcon;
/// 设置终点图标尺寸,默认图片尺寸
@property (nonatomic, assign) CGSize endPointIconSize;
/// 设置终点图标偏移量,默认图片底部中心在经纬度位置(0.0,-0.5),X轴负数向左,Y轴负数向上片,范围值-0.5~0.5
@property (nonatomic, assign) CGPoint endPointIconOffset;
/// 设置导航(小车)图标
@property (nonatomic, strong) UIImage *navigationIcon;
/// 设置导航(小车)图标尺寸,默认图片尺寸
@property (nonatomic, assign) CGSize navigationIconSize;
/// 是否展示用户实时方向,设置后会从dataSource获取实时数据
@property (nonatomic, assign) BOOL needFllowPhoneHeading;
/// 是否支持绘制罗盘,默认NO
@property (nonatomic, assign) BOOL needDrawCompass;
/// 设置罗盘图标
@property (nonatomic, strong, nullable) UIImage *compassIcon;
/// 设置罗盘图标尺寸,默认图片尺寸
@property (nonatomic, assign) CGSize compassIconSize;
/// 设置路线颜色,默认:#50D27D
@property (nonatomic, strong) UIColor *routeColor;
/// 设置路线线宽,默认:10point,范围1~30point
@property (nonatomic, assign) CGFloat lineWidth;
/// 走过路线绘制模式。默认BMKRoutePassedDisplayModeNone,无任何效果
@property (nonatomic, assign) BMKRoutePassedDisplayMode routePassedDisplayMode;
/// 设置经过的路线颜色
@property (nonatomic, strong) UIColor *routePassedColor;
/// 设置路线路况颜色数组,count必须为5,默认按顺序为未知:#0000FF 畅通:#50D27D 缓行:#FFD046 拥挤:#E72110 严重拥堵:#B4170A
@property (nonatomic, strong) NSArray<UIColor *> *trafficColor;
@property (nonatomic, strong) NSArray *trafficColor;

//已走过路线展示方式
typedef NS_ENUM (NSInteger, BMKRoutePassedDisplayMode) {
BMKRoutePassedDisplayModeNone, // 无效果
BMKRoutePassedDisplayModeErased, //擦除
BMKRoutePassedDisplayModeGrayed //置灰
};

//已走过途径点展示方式
typedef NS_ENUM (NSInteger, BMKViaPointPassedDisplayMode) {
BMKViaPointPassedDisplayModeNone, // 无效果
BMKViaPointPassedDisplayModeErased, //擦除
BMKViaPointPassedDisplayModeGrayed //置灰
};

上一篇

步骑行导航多实例

下一篇

步行行前多路线

本篇文章对您是否有帮助?