当我需要做一个MKCoordinateRegion
,我执行以下操作:
var region = MKCoordinateRegion
.FromDistance(coordinate, RegionSizeInMeters, RegionSizeInMeters);
非常简单 - 完美运行。
现在我想存储当前区域的值span。当我看着region.Span
值,它是一个MKCoordinateSpan
它有两个属性:
public double LatitudeDelta;
public double LongitudeDelta;
我怎样才能转换LatitudeDelta
值转化为latitudinalMeters
请? (所以我可以使用上述方法重新创建我的区域(稍后)......
正如我所看到的,您已经有了地图的区域。它不仅包含纬度和经度三角洲,还包含该区域的中心点。您可以计算以米为单位的距离,如图所示:
1:获取区域跨度(区域有多大,以纬度/经度为单位)
MKCoordinateSpan span = region.span;
2:获取区域中心(纬度/经度坐标)
CLLocationCoordinate2D center = region.center;
3:根据中心位置创建两个位置(loc1和loc2,北 - 南)并计算之间的距离(以米为单位)
//get latitude in meters
CLLocation *loc1 = [[CLLocation alloc] initWithLatitude:(center.latitude - span.latitudeDelta * 0.5) longitude:center.longitude];
CLLocation *loc2 = [[CLLocation alloc] initWithLatitude:(center.latitude + span.latitudeDelta * 0.5) longitude:center.longitude];
int metersLatitude = [loc1 distanceFromLocation:loc2];
4:根据中心位置创建两个位置(loc3和loc4,西-东)并计算之间的距离(以米为单位)
//get longitude in meters
CLLocation *loc3 = [[CLLocation alloc] initWithLatitude:center.latitude longitude:(center.longitude - span.longitudeDelta * 0.5)];
CLLocation *loc4 = [[CLLocation alloc] initWithLatitude:center.latitude longitude:(center.longitude + span.longitudeDelta * 0.5)];
int metersLongitude = [loc3 distanceFromLocation:loc4];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)