gpt4 book ai didi

ios - 如何在多个标记之间绘制折线?

转载 作者:行者123 更新时间:2023-11-28 05:55:09 26 4
gpt4 key购买 nike

想要从 userLocation 到多个标记绘制折线。在我的代码中,已经在数组中添加了标记坐标,然后将 userLocation 添加到该数组的第 0 个位置。现在我想在数组元素之间绘制一条路径折线。我的代码如下...

self.coods.append(self.currentLocation)

let jsonResponse = response.data
do{

let json = try JSON(data: jsonResponse!)
self.dictXYZ = [json]
print("JsonResponse printed \(json["data"][0]["lattitude"])")
if let array = json["data"].array{
for i in 0..<array.count{
var coordinate = CLLocationCoordinate2D()
coordinate.latitude = array[i]["lattitude"].doubleValue
coordinate.longitude = array[i]["longitude"].doubleValue

self.coods.append(coordinate)
}

for j in self.coods {

let marker = GMSMarker()

marker.position = j
let camera = GMSCameraPosition.camera(withLatitude: j.latitude, longitude: j.longitude, zoom: 12)

self.mapView.camera = camera
marker.map = self.mapView
}

最佳答案

let path = GMSMutablePath()
for j in self.coods {
path.add(j)
}
let polyline = GMSPolyline(path: path)
polyline.map = mapView

关于ios - 如何在多个标记之间绘制折线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51683979/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com