标签:io ar os sp on cti bs ad ef
ios开发中常常会用到地图控件MKMapView,可以用如下方法在点击MKMapView中某点的时候获取改点的经纬度:
假如声明了一个MKMapView为myMapView
1、在地图中添加一个手势,这个手势是一个点击动作,点击时会调用tapPress这个方法
UITapGestureRecognizer *mTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapPress:)];
[myMapView addGestureRecognizer:mTap];
[mTap release];
2、接下来就可以在tapPress这个方法中进行转换了
- (void)tapPress:(UIGestureRecognizer*)gestureRecognizer {
CGPoint touchPoint = [gestureRecognizer locationInView:myMapView];//这里touchPoint是点击的某点在地图控件中的位置
CLLocationCoordinate2D touchMapCoordinate =
[myMapView convertPoint:touchPoint toCoordinateFromView:myMapView];//这里touchMapCoordinate就是该点的经纬度了
}
标签:io ar os sp on cti bs ad ef
原文地址:http://www.cnblogs.com/zhangshan/p/4093599.html