应客户要求需要限制地图的显示范围,但因了解不深,所以效果总是不理想。终小有体会,留记以醒。
先看官方文档:
MKCoordinateSpan
A structure that defines the area spanned by a map region.
typedef struct {
CLLocationDegrees latitudeDelta;
CLLocationDegrees longitudeDelta;
} MKCoordinateSpan;
Fields
latitudeDelta
The amount of north-to-south distance (measured in degrees) to display on the map. Unlike longitudinal distances, which vary based on the latitude, one degree of latitude is always approximately 111 kilometers (69 miles).
longitudeDelta
The amount of east-to-west distance (measured in degrees) to display for the map region. The number of kilometers spanned by a longitude range varies based on the current latitude. For example, one degree of longitude spans a distance of approximately 111 kilometers (69 miles) at the equator but shrinks to 0 kilometers at the poles.
Discussion
You use the delta values in this structure to indicate the desired zoom level of the map, with smaller delta values corresponding to a higher zoom level.
Availability
- Available in iOS 3.0 and later.
Declared In
MKGeometry.h
按上文理解,假设屏幕宽度固定,随着地图的上下拖动,longitudeDe应该相应的变化,越接近赤道数值越小。但是实际测试后发现,是latitudeDelta变化,而且是越靠近两极数值越小,位于赤道时最大。地球是椭球形,上面的文档应该无错,但不知道什么实际结果却不同?如果有高人来访,还望指点。