2010-12-13 130 views
0

我如何獲取當前地圖範圍,I.E在我的mapview中當前地區的最小x,y和最大x,y?獲取當前地圖範圍

好的 - 現在下面的作品。

MKCoordinateRegion region=map.region; 
MKCoordinateSpan span=map.region.span; 

CLLocationCoordinate2D center=region.center; 
float lat=center.latitude; 
float lon=center.longitude; 

float spanLat=span.latitudeDelta/2; 
float spanLon=span.longitudeDelta/2; 

NSLog(@"Center Lat: %f",lat); 
NSLog(@"Center Lon: %f",lon); 
NSLog(@"span Lat: %f",spanLat); 
NSLog(@"span Lon: %f",spanLon); 

float minLat=lat-spanLat; 
float minLon=lon-spanLon; 
float maxLat=lat+spanLat; 
float maxLon=lon+spanLon; 

回答

0

[mkMapViewObject region]返回一個包含一箇中心點和緯度/經度跨度爲正在顯示的內容的MKCoordinateRegion。