理解MapKit坐标系的困难 [英] Difficulties understanding MapKit Coordinate System
问题描述
我读了苹果文档
地图点是墨卡托地图投影上的x和y值
点是与UIView的坐标系相关联的图形单元
"A map point is an x and y value on the Mercator map projection" A point is a graphical unit associated with the coordinate system of a UIView
Point和MKPoint之间逻辑上有什么区别?
我显然需要CGPoint在屏幕上显示内容。
为什么MapKit需要MKMapPoint?
What is the difference logically between a Point and a MKPoint? I obviously need CGPoint to display something on the screen. So why does MapKit need MKMapPoint?
推荐答案
CGPoint
和 MKMapPoint
结构碰巧存储两个名为 x
和 y
无关紧要。
The fact that both the CGPoint
and MKMapPoint
structs happen to store two floating-point values named x
and y
is irrelevant.
它们被赋予不同的名称,因为它们在逻辑上处理不同的坐标系,变换,范围和尺度。
They are given different names because they logically deal with different coordinate systems, transformations, ranges and scales.
2D世界地图需要一个大的固定坐标系统,允许将经度和经度转换为地图上的固定点,无论如何部分当前正在屏幕上显示的内容。
A 2D world map needs a large, fixed coordinate system that allows a latitude and longitude to be converted to a fixed point on the map regardless of what portion is currently being displayed on the screen.
MKMapPoint的范围
值很大,因为它们需要以足够高的分辨率(超出屏幕尺寸)来表示世界的坐标。
The range of MKMapPoint
values are large since they need to represent the world's coordinates at a high-enough resolution (well beyond screen sizes).
然而,你并不需要关心 MKMapPoint
的实际值。有时,您可能需要将 CLLocationCoordinate2D
转换为 MKMapPoint
(或其他方式),但您不需要需要担心这些值,也不应该存储它们(文档建议不要这样做,因为内部投影计算将纬度和经度转换为2D投影可能会在iOS版本之间发生变化)。
However, you don't exactly need to care about the actual values of an MKMapPoint
. Occasionally, you may need to convert a CLLocationCoordinate2D
to an MKMapPoint
(or the other way around) but you don't need to worry about those values nor should you store them (the docs recommend not doing this since the internal projection calculations to convert a latitude and longitude to a 2D projection may change between iOS releases).
您对 MKMapPoint
的使用仅基于您处理地图的2D投影独立设备的屏幕尺寸或者地图的当前部分当前正在显示。
Your usage of an MKMapPoint
is only on the basis that you are dealing with the map's 2D projection independent of the device's screen size or what portion of the map is currently displaying.
我显然需要CGPoint在屏幕上显示一些东西。
I obviously need CGPoint to display something on the screen.
是的但是在添加注释或叠加时,你通常会处理 CLLocationCoordinate2D
值,让地图视图根据需要进行转换。
Yes but when adding annotations or overlays, you generally deal with CLLocationCoordinate2D
values and let the map view do the conversion as needed.
这篇关于理解MapKit坐标系的困难的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!