全部服务产品
开发者频道
定价
登录
绘制动态轨迹
下载开发文档
绘制动态轨迹简介

Since6.6.1起支持3D动态轨迹绘制,开发者可以提供轨迹数据,来动态展示3D轨迹。支持监听轨迹绘制状态。

开始绘制3D轨迹
1. 构造BMK3DTraceOverlay对象
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;
}
2. 实现代理方法生成对应的view(BMKTraceOverlayView)
#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;
}
3. 轨迹动画相关回调
#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(@"动画结束");
}
4. 运行程序

效果如下:

上一篇

文字覆盖物

下一篇

蜂窝热力图

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