#import <BaiduMapAPI_Map/BMKMapComponent.h>// 创建BMKBackgroundMapView_backgroundMapView = [BMKBackgroundMapView new];// 设置_backgroundMapView的frameself.backgroundMapView.frame = CGRectMake(0, 150, self.view.frame.size.width, 700);
// 1.获取多实例地图的BMKMapViewBMKMapView *mapView = [self.multiNaviView getNaviMapView]//2.BMKMapView设置支持后台绘制[mapView setSupportBackgroundDraw:YES];//3.关联到BMKBackgroundMapViewself.backgroundMapView.mapview = mapView;
// 从导航组建从获取BMKBackgroundNavigationView,并关联到BMKBackgroundMapViewself.backgroundMapView.navigationView = [[BMKCycleNavigationManager sharedManager] getBackgroundNavigationView];
[self.view addSubview:self.backgroundMapView];
// 建议监听系统进出前后台通知,控制绘制开始/停止[self.backgroundMapView startRender];[self.backgroundMapView stopRender];
/// 帧率控制,默认30帧/s,范围10~60帧/s@property (nonatomic, assign) NSInteger frameRate;
/// 3D绘制@property (nonatomic, assign) BOOL enable3D;
/// 开始渲染- (void)startRender;/// 结束渲染- (void)stopRender;
/// 获取背景图层,用于自定义背景颜色,设置UIView的backgroundColor即可@property (nonatomic, readonly) UIView *backgroundView;
/// 获取路网图层,用于自定义路网颜色@property (nonatomic, readonly) BMKBackgroundRoadNetView *roadNetView;
5.1 自定义路网颜色
/// 设置路网颜色@property (nonatomic, strong) UIColor *roadNetColor;
/// 获取导航图层,用于自定义导航路线宽度,颜色(驾车导航路线路况颜色,走过置灰或擦除,置灰颜色),路线数据更新;/// 用于自定义导航小车图标及大小,位置方向更新,罗盘是否显示,小车车头是否跟随手机旋转@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 //置灰};
上一篇
下一篇
本篇文章对您是否有帮助?