如何将相机动画化为折线(谷歌地图)



我有像"s_~fGwyptMSkFnBK"这样的折线字符串。

(斯威夫特4(

let polyline = GMSPolyline(path: GMSPath(fromEncodedPath:polylineString))
polyline.map = self.mapView

如何将相机动画化到这条折线?

您需要读取折线的第一个和最后一个坐标,并以这种方式对摄像机移动进行动画处理。

let vancouver = CLLocationCoordinate2D(latitude: 49.26, longitude: -123.11)
let calgary = CLLocationCoordinate2D(latitude: 51.05,longitude: -114.05)
let bounds = GMSCoordinateBounds(coordinate: vancouver, coordinate: calgary)
let camera = mapView.camera(for: bounds, insets: UIEdgeInsets())!
mapView.camera = camera

https://developers.google.com/maps/documentation/ios-sdk/views

最新更新