Since6.6.1起支持3D动态轨迹绘制,开发者可以提供轨迹数据,来动态展示3D轨迹。支持监听轨迹绘制状态。
BMK3DTraceOverlay *traceOverlay = [BMK3DTraceOverlay traceOverlay3DWithCoordinates:_coords count:_coordsCount option:self.traceOption];traceOverlay.delegate = self;[self.mapView addOverlay:traceOverlay];/// 轨迹动画选项- (BMK3DTraceOverlayOption *)traceOption {if (!_traceOption) {_traceOption = [[BMK3DTraceOverlayOption alloc] init];// 轨迹样式_traceOption.traceType = BMK3DTraceOverlayTypeDefault;// 动画时间_traceOption.duration = 10.0;_traceOption.easingCurve = BMK3DTraceOverlayAnimationEasingCurveLinear;// 轨迹绘制的透明度,取值范围[0.0, 1.0], 默认1.0_traceOption.opacity = 0.8;// 轨迹投影面的透明度,取值范围[0.0, 1.0], 默认1.0_traceOption.paletteOpacity = 1.0;// 调色板图片(3D轨迹线高度面的取色板)_traceOption.paletteImage = [UIImage imageNamed:@"bule_wall_128x128"];// 投影调色板图片 (贴合底图的2D轨迹线的取色板)_traceOption.projectionPaletteImage = [UIImage imageNamed:@"red_wall_64x64"];}return _traceOption;}
#pragma mark - <BMKMapViewDelegate>- (__kindof BMKOverlayView *)mapView:(BMKMapView *)mapView viewForOverlay:(id<BMKOverlay>)overlay {if ([overlay isKindOfClass:[BMK3DTraceOverlay class]]) {BMK3DTraceOverlayView *traceOverlayView = [[BMK3DTraceOverlayView alloc] initWithTraceOverlay:overlay];/// 3D效果的高度/// 注意:strokeHeights 长度与轨迹点的个数必须保持一致traceOverlayView.strokeHeights = [_heights copy];traceOverlayView.lineWidth = 12.0;return traceOverlayView;}return nil;}
#pragma mark - <BMK3DTraceOverlayAnimationDelegate>/// 动画开始- (void)traceOverlayAnimationDidStart:(BMK3DTraceOverlay *)traceOverlay {NSLog(@"动画开始");}/// 动画进度/// @param traceOverlay BMK3DTraceOverlay/// @param progress 进度 0.0 ~ 100.0- (void)traceOverlay:(BMK3DTraceOverlay *)traceOverlay animationRunningProgress:(CGFloat)progress {NSLog(@"动画进度:%.1f", progress);}/// 追踪动画实时位置/// @param traceOverlay BMK3DTraceOverlay/// @param position 当前位置- (void)traceOverlay:(BMK3DTraceOverlay *)traceOverlay animationTraceMovePosition:(CLLocationCoordinate2D)position {NSLog(@"动画实时位置:%lf, %lf", position.latitude, position.longitude);}/// 动画结束/// @param traceOverlay BMK3DTraceOverlay/// @param flag 动画是否完成- (void)traceOverlay:(BMK3DTraceOverlay *)traceOverlay animationDidEnd:(BOOL)flag {NSLog(@"动画结束");}
效果如下:
上一篇
下一篇
本篇文章对您是否有帮助?