Swift 将纬度和经度编码为折线

Swift Encode Lat&Lon to Polyline

我有一个经纬度列表,想在地图上将其显示为路径。我可以使用 GMSPath(fromEncodePath: polyline) 在地图上显示折线。

如何将经纬度列表转换为折线或将其显示在地图上?

非常感谢!

您可以从这样的坐标创建路径

let path = GMSMutablePath()
path.add(CLLocationCoordinate2DMake(29.520,30.856))
path.add(CLLocationCoordinate2DMake(25.17,40.1235))
let pLine = GMSPolyline.init(path: path)