Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在swift中从一个坐标移动标记而不偏离道路_Ios_Swift_Google Maps_Google Maps Markers - Fatal编程技术网

Ios 如何在swift中从一个坐标移动标记而不偏离道路

Ios 如何在swift中从一个坐标移动标记而不偏离道路,ios,swift,google-maps,google-maps-markers,Ios,Swift,Google Maps,Google Maps Markers,我正在谷歌地图上工作,我正在通过设置标记位置和从服务器获得的新坐标来移动地图上的标记 但这里我的问题是marker离开了公路,直接去了新的地点,它没有沿着公路走 这里我的要求是,标记应该穿过道路,将一个点移动到另一个点 CATransaction.begin() CATransaction.setValue(2.0, forKey: kCATransactionAnimationDuration) CATransaction.setCompletionBlock { self.marke

我正在谷歌地图上工作,我正在通过设置标记位置和从服务器获得的新坐标来移动地图上的标记

但这里我的问题是marker离开了公路,直接去了新的地点,它没有沿着公路走

这里我的要求是,标记应该穿过道路,将一个点移动到另一个点

CATransaction.begin()
CATransaction.setValue(2.0, forKey: kCATransactionAnimationDuration)
CATransaction.setCompletionBlock {
    self.marker.groundAnchor = CGPoint(x: 0.5, y: 0.5)
}
self.mapView.animate(to: GMSCameraPosition.camera(withLatitude: self.lat, longitude: self.lon, zoom: 15))
self.marker.position = CLLocationCoordinate2D(latitude: self.lat, longitude: self.lon)
CATransaction.commit()
self.marker.map = self.mapView

这是我用来在地图上设置标记的代码。

您更新标记位置的频率是多少?@HardikS位置来自服务器,我在这里设置此位置并将标记移动到新位置,但当有转弯时,标记不是通过道路移动的,只是穿过地图。这需要额外的逻辑和更多如果要执行此操作,请从服务器获取坐标。。默认情况下,它将针从一个点移动到另一个点。不,您应该拥有服务器上所有要显示标记的点,它不会自动移动到路由。您必须使用方向api将路径移动到新位置,然后使用该路径移动标记。