應客戶要求須要限制地圖的顯示範圍,但因瞭解不深,因此效果老是不理想。終小有體會,留記以醒。 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變化,並且是越靠近兩極數值越小,位於赤道時最大。地球是橢球形,上面的文檔應該無錯,但不知道什麼實際結果卻不一樣?若是有高人來訪,還望指點。