Ios 使用谷歌地图上的动画在多个位置之间移动标记

Ios 使用谷歌地图上的动画在多个位置之间移动标记,ios,swift,google-maps,Ios,Swift,Google Maps,我想在两个位置坐标之间移动一个汽车图标,我想通过滑块更改该汽车图标的持续时间(速度) 我试着用CATTransaction来设置标记的动画。它的动画效果很好,但我无法通过滑块实时更改持续时间(速度) 下面是我为标记设置动画的代码 func moveTo(点:CLLocationCoordinate2D){ 如果let marker=arrMapList[0]作为GMSMarker{ let angle=getAngle(从LoAction:marker.position,到Location:po

我想在两个位置坐标之间移动一个汽车图标,我想通过滑块更改该汽车图标的持续时间(速度)

我试着用CATTransaction来设置标记的动画。它的动画效果很好,但我无法通过滑块实时更改持续时间(速度)

下面是我为标记设置动画的代码

func moveTo(点:CLLocationCoordinate2D){
如果let marker=arrMapList[0]作为GMSMarker{
let angle=getAngle(从LoAction:marker.position,到Location:points[currentIndex])
marker.rotation=CLLocationDegrees(角度*(180.0/.pi))
CATransaction.begin()
CATTransaction.setAnimationDuration(5)
CATransaction.setCompletionBlock{
如果让nextPoint=self.getNextPoint(currentIndex:self.currentIndex){
self.moveTo(点:nextPoint)
}
}
marker.position=点
CATransaction.commit()
}
}
我试图改变持续时间如下,但它不工作

@iAction func SliderValueChanged(u发件人:UISlider){
CATransaction.setAnimationDuration(CFTimeInterval(sender.value))
}

标记(汽车)图标应在两个坐标之间移动,如果用户通过向左或向右移动滑块来更改速度值,动画持续时间应受到影响。

您不能更改飞行中动画的持续时间

您应该能够更改图层的“速度”参数以加快速度

速度=1.0为正常速度。速度2.0会快一倍(持续时间的一半)。0.5的速度是半速

您将使用如下代码

marker.layer.speed = 2.0

(您需要重构以设置滑块的速度。请尝试从0.5到1.5的范围。)

感谢您回答Duncan C。但当我移动滑块时,它会将maker快速移动到目标点,而不是通过我从滑块设置的速度。