获取当前地图范围
我如何获取当前地图范围,即地图视图中当前区域的最小 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;
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
[mkMapViewObject region]
返回一个 MKCooperativeRegion,其中包含所显示内容的中心点和纬度/经度跨度。[mkMapViewObject region]
returns an MKCoordinateRegion that contains a center point and a lat/long span for what is being displayed.