MKCoordinateRegionMakeWithDistance的反向功能? [英] Reverse function of MKCoordinateRegionMakeWithDistance?

查看:251
本文介绍了MKCoordinateRegionMakeWithDistance的反向功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MapKit的内置函数MKCoordinateRegionMakeWithDistance以米为单位将距离转换为MKCoordinateRegion:

MapKit's built in function MKCoordinateRegionMakeWithDistance takes distances in meters and turns them into a MKCoordinateRegion:

func MKCoordinateRegionMakeWithDistance(
    _ centerCoordinate: CLLocationCoordinate2D, 
    _ latitudinalMeters: CLLocationDistance, 
    _ longitudinalMeters: CLLocationDistance) 
        -> MKCoordinateRegion

是否有一个倒数功能需要一个MKCoordinateRegion并给我纬度和经度?

is there a reverse function that takes a MKCoordinateRegion and gives me latitudinalMeters and longitudinalMeters?

推荐答案

MKCoordinateRegion给出中心(纬度和经度)和跨度(delta纬度和经度).给定这些值,您可以确定纬度和经度区域边缘的位置.完成此操作后,您可以使用Haversine公式获取纬向和纵向距离,并且您已经知道中心.实际上,CLLocation具有函数distanceFromLocation:(const CLLocation *)location,应使用该函数避免直接执行该公式.

MKCoordinateRegion gives a center (latitude and longitude) and span (delta latitude and longitude). Given these values, you can determine the location of the edges of the region in latitude and longitude. Once you do that, you can use the haversine formula to obtain latitudinal and longitudinal distances, and you already know the center. In fact, CLLocation has a function distanceFromLocation:(const CLLocation *)location which you should use to avoid a direct implementation of the formula.

这篇关于MKCoordinateRegionMakeWithDistance的反向功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆