如何在iPhone上根据用户触摸地图上的位置获取mkmapview中的位置坐标?
如何在iPhone上根据用户触摸地图上的位置获取mkmapview中的位置坐标?
func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches {
let touchPoint = touch.location(in: mapView)
let location = mapView.convert(touchPoint, toCoordinateFrom: mapView)
print ("\(location.latitude), \(location.longitude)")
}
}
-(void)didTouchMap:(UITapGestureRecognizer*)tapGesure {
CGPoint touchPoint = [tapGesure locationInView:selectLocationMapView];
CLLocationCoordinate2D coord= [selectLocationMapView convertPoint:touchPoint toCoordinateFromView:selectLocationMapView];
NSLog(@"lat %f",coord.latitude);
NSLog(@"long %f",coord.longitude);
}