开发者

get current map extent

开发者 https://www.devze.com 2023-01-30 19:12 出处:网络
How can i get the current map extent, I.E the min x,y and max x,y for开发者_运维问答 my current region in my mapview?

How can i get the current map extent, I.E the min x,y and max x,y for开发者_运维问答 my current region in my mapview?

Okay- The below works now.

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;


[mkMapViewObject region] returns an MKCoordinateRegion that contains a center point and a lat/long span for what is being displayed.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号