应客户要求须要限制地图的显示范围,但因了解不深,因此效果老是不理想。终小有体会,留记以醒。 git
先看官方文档: app
MKCoordinateSpan 测试
A structure that defines the area spanned by a map region. this
typedef struct { CLLocationDegrees latitudeDelta; CLLocationDegrees longitudeDelta; } MKCoordinateSpan;
Fields spa
latitudeDelta code
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 it
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. io
Discussion ast
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
Declared In
MKGeometry.h
按上文理解,假设屏幕宽度固定,随着地图的上下拖动,longitudeDe应该相应的变化,越接近赤道数值越小。可是实际测试后发现,是latitudeDelta变化,并且是越靠近两极数值越小,位于赤道时最大。地球是椭球形,上面的文档应该无错,但不知道什么实际结果却不一样?若是有高人来访,还望指点。