简体   繁体   English

MKCoordinateSpan和CLLocationCoordinate2D有什么区别

[英]What is the difference between MKCoordinateSpan and CLLocationCoordinate2D

I was going through the sample example of MapKit and CoreLocation framework. 我正在浏览MapKitCoreLocation框架的示例示例。 I found these two structs ( MKCoordinateSpan and CLLocationCoordinate2D ) which are similar in declaration. 我发现这两个结构( MKCoordinateSpanCLLocationCoordinate2D )在声明中相似。 How are these different in functionality, can someone please site an example (using both) to clear their meanings. 这些功能在功能上有何不同,有人可以举一个例子(同时使用两者)以阐明其含义。

Thanks! 谢谢!

MKCoordinateSpan defines a span , ie a delta, in the latitude and longitude directions to show on a map. MKCoordinateSpan定义了在地图上显示的经度和纬度方向的跨度 ,即增量。 Along with a point you can then define a region to display on a map. 然后,您可以与一个点一起定义要在地图上显示的区域。

CLLocationCoordinate2D defines a single point in the latitude and longitude coordinate system. CLLocationCoordinate2D定义纬度和经度坐标系中的单个点。

For example: 例如:

|<---- deltaLat  ---->|
|---------------------|---
|                     | |
|                     | |
|                     | |
|                     | |
|          +          |deltaLon
|      (lat,lon)      | |
|                     | |
|                     | |
|                     | |
|---------------------|---

Here you can imagine a centre point (lat,lon) about which you have a deltaLat and a deltaLon . 在这里,您可以想象一个中心点(lat,lon)围绕该deltaLat有一个deltaLat和一个deltaLon

So (lat,lon) would be a CLLocationCoordinate2D and deltaLat, deltaLon would form a MKCoordinateSpan . 因此(lat,lon)将是CLLocationCoordinate2DdeltaLat, deltaLon将形成MKCoordinateSpan

You're right that both structures are defined in the same way, but this is quite common where the two different structures have different semantics and therefore are defined separately like you've found. 没错,两个结构都以相同的方式定义,但这在两个不同的结构具有不同语义并因此像您所发现的那样分别定义的情况下很常见。

MKCoordinateSpan is interpreted as delta values , whereas CLLocationCoordinate2D is interpreted as a point . MKCoordinateSpan被解释为增量值 ,而CLLocationCoordinate2D被解释为一个

For example, let's say you want to define a circular region, you would define a center point, and the radius around it. 例如,假设您要定义一个圆形区域,您将定义一个中心点及其周围的半径。

In MapKit , you define a rectangular region by MKCoordinateRegion . MapKit ,可以通过MKCoordinateRegion定义一个矩形区域 The center point is a CLLocationCoordinate2D ( latitude and longitude - both typedef of double ) and a vertical and horizontal delta by MKCoordinateSpan ( latitudeDelta and longitudeDelta - both typedef of double ) 中心点是一个CLLocationCoordinate2Dlatitudelongitude -的两端的typedef double ),并通过一垂直和水平增量MKCoordinateSpanlatitudeDeltalongitudeDelta -的两端的typedef double

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM