开发者

What event is fired when MKMAPVIEW extent changes

What event is fired when the MKMAPVIEW changes extent (zooms in or out, panning)?

I need to get the coordinates that are used to d开发者_如何学Pythonisplay the map.


You should adopt the MKMapViewDelegate protocol and implement mapView:regionDidChangeAnimated: method which will be called in the event the region changes. However since it will be called many times when scrolling you should take that into consideration before implementing that method.

Getting the Top-Left coordinate of the map

CLLocationCoordinate2D topLeftCoordinate = [self.mapView convertPoint:CGPointMake(0,0)
                                                 toCoordinateFromView:self.mapView];

Or

Since you know the region already,

MKCoordinateRegion region = self.mapView.region;
MKCoordinateSpan span = region.span;
CLLocationCoordinate2D center = region.center;

CLLocationCoordinate2D topLeftCoordinate = CLLocationCoordinate2DMake(center.latitude - span.latitudeDelta / 2, center.longitude - span.longitudeDelta / 2);
/* Similarly, get the others  */
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜