gpt4 book ai didi

ios - 用google direction api绘制路径

转载 作者:行者123 更新时间:2023-11-29 00:26:27 25 4
gpt4 key购买 nike

enter image description here

我正在尝试使用 google direction api 在多个地方之间绘制路径,但问题是当我缩放 map 时,路径绘制不正确。

我正在点击此 api 并使用来自 JSON 响应的“overview_polyline”点绘制路径。

https://maps.googleapis.com/maps/api/directions/json?origin=(startLocationLat),(startLocationLong)&destination=(endLocationLat),(endLocationLong)&waypoints=(self.wayPointBetweenLocations)&key=AIzaSyCK0dxRGRlFqM84SUM3zbVQAdbXEXtN-x0&mode=driving

let polygon = GMSPolygon()
polygon.path = GMSPath(fromEncodedPath: "\(self.overview_points)")

请帮我解决这个问题。谢谢

最佳答案

使用GMSPolyline而不是GMSPolygon来绘制路径。

示例:

    let path = GMSPath(fromEncodedPath: "\(self.overview_points)")
let directionPolyline = GMSPolyline(path: path)
directionPolyline.strokeColor = UIColor.blue
directionPolyline.strokeWidth = 3
directionPolyline.map = self.mapView

关于ios - 用google direction api绘制路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42889685/

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