从给定 MKMapView 的当前边界获取 latitude/longitude 度的大小
Get size in latitude/longitude degrees from the current boundaries given a MKMapView
Apple 开发者文档谈到 "map points" 获取当前显示的地图的可见部分。
什么是地图点?它与 latitude/longitude 度有什么关系?
什么是地图点?
From the MKMapPoint docs -
If you project the curved surface of the globe onto a flat surface, what you get is a two-dimensional version of a map where longitude lines appear to be parallel. Such maps are often used to show the entire surface of the globe all at once. An MKMapPoint
data structure represents a point on this two-dimensional map.
The actual units of a map point are tied to the underlying units used to draw the contents of an MKMapView
, but you should never need to worry about these units directly. You use map points primarily to simplify computations that would be complex to do using coordinate values on a curved surface. By converting to map points, you can perform those calculations on a flat surface, which is generally much simpler, and then convert back as needed. You can map between coordinate values and map points using the init(_:)
and coordinate functions.
When saving map-related data to a file, you should always save coordinate values (latitude and longitude) and not map points.
它与 latitude/longitude 度有什么关系?
You can create a new MKMapPoint
instance by using CLLocationCoordinate2D
value(which can be created using latitude
& longitude
values.) See - MKMapPoint.init(_ coordinate:)
对于 get the visible portion of the map that is currently displayed
部分,您可以使用 -
向 MKMapView
实例询问此信息
更新
以下是计算 latitude
和 longitude
的 min/max 值的方法。
let region = mapView.region
let center = region.center
let span = region.span
let minLatitude = (center.latitude - span.latitudeDelta/2)
let maxLatitude = (center.latitude + span.latitudeDelta/2)
let minLongitude = (center.longitude - span.longitudeDelta/2)
let maxLongitude = (center.longitude + span.longitudeDelta/2)
Apple 开发者文档谈到 "map points" 获取当前显示的地图的可见部分。
什么是地图点?它与 latitude/longitude 度有什么关系?
什么是地图点?
From the MKMapPoint docs -
If you project the curved surface of the globe onto a flat surface, what you get is a two-dimensional version of a map where longitude lines appear to be parallel. Such maps are often used to show the entire surface of the globe all at once. An
MKMapPoint
data structure represents a point on this two-dimensional map.The actual units of a map point are tied to the underlying units used to draw the contents of an
MKMapView
, but you should never need to worry about these units directly. You use map points primarily to simplify computations that would be complex to do using coordinate values on a curved surface. By converting to map points, you can perform those calculations on a flat surface, which is generally much simpler, and then convert back as needed. You can map between coordinate values and map points using theinit(_:)
and coordinate functions.When saving map-related data to a file, you should always save coordinate values (latitude and longitude) and not map points.
它与 latitude/longitude 度有什么关系?
You can create a new
MKMapPoint
instance by usingCLLocationCoordinate2D
value(which can be created usinglatitude
&longitude
values.) See - MKMapPoint.init(_ coordinate:)
对于 get the visible portion of the map that is currently displayed
部分,您可以使用 -
MKMapView
实例询问此信息
更新
以下是计算 latitude
和 longitude
的 min/max 值的方法。
let region = mapView.region
let center = region.center
let span = region.span
let minLatitude = (center.latitude - span.latitudeDelta/2)
let maxLatitude = (center.latitude + span.latitudeDelta/2)
let minLongitude = (center.longitude - span.longitudeDelta/2)
let maxLongitude = (center.longitude + span.longitudeDelta/2)