gpt4 book ai didi

ios - 无论如何要在谷歌地图上计算英里或米到像素以计算缩放级别?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:06:45 24 4
gpt4 key购买 nike

很久以来我一直在寻找这个东西。是否有任何数学公式可以将英里或米转换为谷歌地图中缩放级别的像素?任何形式的帮助表示赞赏。我目前正在为 iOS 工作。

最佳答案

我从这里找到了解决方案https://gist.github.com/ryanhanwu/4dbcdbdf384f5a3cca1f
我为 Swift 4 重写了它,如下所示

let topLeft: CLLocationCoordinate2D = mapView.projection.visibleRegion().farLeft
let bottomLeft: CLLocationCoordinate2D = mapView.projection.visibleRegion().nearLeft
let zoom = mapView.camera.zoom
let lat = Double(fabs(Float(topLeft.latitude - bottomLeft.latitude)))
let metersPerPixel: Double = Double((cos(lat * .pi / 180) * 2 * .pi) * 6378137 / Double((256 * pow(2, zoom))))

关于ios - 无论如何要在谷歌地图上计算英里或米到像素以计算缩放级别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37064150/

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