【问题标题】:Bounding box coordinates for MKMapSnapshotter resultMKMapSnapshotter 结果的边界框坐标
【发布时间】:2016-02-08 13:09:55
【问题描述】:

我正在使用MKMapSnapshotter 创建 MKMapView 的快照。这很好用:

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 角的确切坐标。这可能吗?是基于 1000m 距离的一些简单数学运算,还是快照不那么精确?

【问题讨论】:

    标签: ios mkmapview


    【解决方案1】:

    原来它只需要一些简单的数学:

        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)")
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-26
      • 1970-01-01
      • 2019-06-27
      • 2021-08-29
      • 2021-02-20
      • 2019-06-29
      • 2017-10-08
      • 2016-07-07
      相关资源
      最近更新 更多