Since6.4.0起支持动态轨迹绘制,开发者可以提供轨迹数据,来动态展示轨迹。支持监听轨迹绘制状态。Since 6.5.6起iOS地图SDK动态轨迹支持渐变色绘制和.gltf+.bin模型加载,并支持动画播放。
BMKTraceOverlay *traceOverlay = [BMKTraceOverlay traceOverlayWithCoordinates:_coords count:_coordsCount option:self.animationOption];/// 是否使用渐变色轨迹/// 注意:要配合strokeColors使用,否则无效traceOverlay.isGradientColor = YES;/// 是否使用发光轨迹traceOverlay.isTrackBloom = YES;traceOverlay.bloomSpeed = 5.0f;traceOverlay.delegate = self;[self.mapView addOverlay:traceOverlay];/// 轨迹动画选项- (BMKTraceOverlayOption *)animationOption {if (!_animationOption) {_animationOption = [[BMKTraceOverlayOption alloc] init];_animationOption.animate = YES; // 是否动画_animationOption.delay = 0.0; // 动画延迟开始时间_animationOption.duration = 10.0; // 动画时间_animationOption.fromValue = 0.0;_animationOption.toValue = 1.0;_animationOption.easingCurve = BMKTraceOverlayAnimationEasingCurveLinear;_animationOption.trackMove = NO; // 是否跟踪轨迹动画(地图跟随移动)_animationOption.pointMove = YES;BMKTrace3DModelOption *option = [[BMKTrace3DModelOption alloc] init];option.scale = 5;option.modelName = @"scenes";option.rotateX = 90;option.rotateY = -90;option.type = BMK3DModelTypeGLTF;option.modelYawAxis = BMKTraceOverlay3DModelYawAxisY;option.modelPath = [NSString stringWithFormat:@"%@/Model3D", [NSBundle mainBundle].bundlePath];option.animationIsEnable = YES;option.animationSpeed = 1;option.animationRepeatCount = 0;option.animationIndex = 1;_animationOption.modelOption = option;}return _animationOption;}
#pragma mark - <BMKMapViewDelegate>- (__kindof BMKOverlayView *)mapView:(BMKMapView *)mapView viewForOverlay:(id<BMKOverlay>)overlay {if ([overlay isKindOfClass:[BMKTraceOverlay class]]) {BMKTraceOverlayView *polylineView = [[BMKTraceOverlayView alloc] initWithTraceOverlay:overlay];/// 纯色// polylineView.strokeColor = [UIColor blueColor];// polylineView.fillColor = [UIColor blueColor];/// 渐变色颜色/// 注意:strokeColors 长度与轨迹点的个数必须保持一致polylineView.strokeColors = [_colors copy];polylineView.lineWidth = 8.0;return polylineView;}return nil;}
自v6.5.9起支持轨迹暂停和继续
// 暂停轨迹动画绘制[self.traceOverlay pauseTraceOverlayDraw];// 继续轨迹动画绘制[self.traceOverlay resumeTraceOverlayDraw];
效果如下:
上一篇
下一篇
本篇文章对您是否有帮助?