MKMAPVIEW范围更改时会触发什么事件 [英] What event is fired when MKMAPVIEW extent changes
本文介绍了MKMAPVIEW范围更改时会触发什么事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
MKMAPVIEW更改范围(放大或缩小,平移)时会引发什么事件?
What event is fired when the MKMAPVIEW changes extent (zooms in or out, panning)?
我需要获取用于显示地图的坐标.
I need to get the coordinates that are used to display 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.
获取地图的左上角坐标
CLLocationCoordinate2D topLeftCoordinate = [self.mapView convertPoint:CGPointMake(0,0)
toCoordinateFromView:self.mapView];
或
既然您已经知道该地区,
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 */
这篇关于MKMAPVIEW范围更改时会触发什么事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文