如何在 mapbox 地图中使用动画移动注释?

How to move annotation with animation in mapbox map?

我在 iOS 应用程序中使用 mapbox 地图。我使用此 class MGLPointAnnotation.

在 mapbox 地图中添加了注释

现在的问题是我无法更改它的位置。这就是我更改注释位置的方式。但它不动。我需要删除第一个旧注释,然后再次需要添加新注释,但我不想这样做 this.Please 让我知道我该怎么做。

car.coordinate = CLLocationCoordinate2D(latitude: lat, longitude: lng)

我希望注释的位置改变时注释的移动具有流畅的动画效果。

此外,当位置发生变化时,我正在使用相机更改我的 mapbox 地图的中心。让我知道我做得对不对。

// Optionally set a starting point.
bMbMapView.setCenter(cord, zoomLevel: 7, direction: bearing, animated: true)     
bMbMapView.setDirection(bearing, animated: true)

// Create a camera that rotates around the same center point, rotating 180°.
// `fromDistance:` is meters above mean sea level that an eye would have to be in order to see what the map view is showing.
let camera = MGLMapCamera(lookingAtCenter: cord, fromDistance: 1000, pitch: 7, heading: 90)

 // Animate the camera movement over 5 seconds.
 bMbMapView.setCamera(camera, withDuration: 1, animationTimingFunction: CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)) 

MGLAnnotationView 是一个 UIView,因此您应该能够使用 Core Animation 对更改进行动画处理:https://github.com/mapbox/mapbox-gl-native/issues/8378#issuecomment-287910768

另一种选择是使用样式源和图层,然后使用计时器更新源。这可能不如使用动画注释视图流畅。