首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MKMapSnapshotter结果的包围盒坐标

MKMapSnapshotter结果的包围盒坐标
EN

Stack Overflow用户
提问于 2016-01-06 03:16:21
回答 1查看 129关注 0票数 1

我正在使用MKMapSnapshotter创建MKMapView的快照。这是非常有效的:

代码语言:javascript
复制
let centerCoordinate = CLLocationCoordinate2DMake(-33.367348, 115.653591)
options.region = MKCoordinateRegionMakeWithDistance(centerCoordinate, 1000, 1000)
options.mapType = .Standard
options.size = CGSizeMake(2000, 2000)
let snapshotter = MKMapSnapshotter(options: options)
snapshotter.startWithCompletionHandler { snapshot, error in
    if let error = error {
        print(error)
    }
    else if let snapshot = snapshot {
        //process result
    }
}

我想知道的是得到的图像的NE角和SW角的精确坐标。这个是可能的吗?这是一个基于1000米距离的简单数学的例子,还是快照不是那么精确?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-08 05:09:55

事实证明,这需要一些简单的数学:

代码语言:javascript
复制
    func printTranslatedCoordinates(coordinate: CLLocationCoordinate2D, latitudeMetres: Double, longitudeMetres: Double) {
    let region = MKCoordinateRegionMakeWithDistance(coordinate, latitudeMetres, longitudeMetres)
    let span = region.span

    let northLatitude = coordinate.latitude + span.latitudeDelta
    let eastLongitude = coordinate.longitude + span.longitudeDelta
    let southLatitude = coordinate.latitude - span.latitudeDelta
    let westLongitude = coordinate.longitude - span.longitudeDelta
    print("\(westLongitude) \(southLatitude) \(eastLongitude) \(northLatitude)")
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34625045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档