gpt4 book ai didi

ios - 跨越(180 或 -180)经度时 MapBox iOS MGLPolyline 的问题

转载 作者:搜寻专家 更新时间:2023-10-31 22:38:22 26 4
gpt4 key购买 nike

在 MapBox iOS sdk 4.4.1 中,如果 MGLPolyline 穿过(180 或 -180)经度, map 会显示它绕地球的距离更长,而不是更短。

    override func viewDidAppear(_ animated: Bool) {
let points = [
CLLocationCoordinate2D(latitude: 50.0, longitude: -170.0),
CLLocationCoordinate2D(latitude: 50.0, longitude: 170),
]
let line = MGLPolyline(coordinates: points, count: UInt(points.count))
line.title = "line"
mapView.addAnnotation(line)
}

enter image description here

最佳答案

沿纬度和/或经度递增的线连接连续的点是有道理的,但默认情况下。可在此处找到 Mapbox 关于如何为 MGLPolyline 克服此问题的信息。

感兴趣的部分是:Mapbox MGLPolyline link

To make the polyline go across the antimeridian or international date line, specify some longitudes less than −180 degrees or greater than 180 degrees. For example, a polyline that stretches from Tokyo to San Francisco would have coordinates of (35.68476, -220.24257) and (37.78428, -122.41310).

因此,他们将其留给开发人员来实现他们自己的逻辑来决定何时以及是否适合走更长或更短的路线。

关于ios - 跨越(180 或 -180)经度时 MapBox iOS MGLPolyline 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52584818/

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