ユーザーがビューを長押ししたときに、地図ビューから GPS 座標を取得したいと考えています。
現在私は使用しています:
- (void)viewDidLoad
{
[super viewDidLoad];
mapView.showsUserLocation =YES;
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(mapLongPress:)];
longPressGesture.minimumPressDuration = 1.5;
[mapView addGestureRecognizer:longPressGesture];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)mapLongPress:(UILongPressGestureRecognizer *)gestureRecognizer{
if(gestureRecognizer.state == UIGestureRecognizerStateBegan){
CGPoint touchLocation = [gestureRecognizer locationInView:mapView];
CLLocationCoordinate2D coordinate;
coordinate = [mapView convertPoint:touchLocation toCoordinateFromView:mapView];// how to convert this to a String or something else?
NSLog(@"Longpress");
}
}
しかし、どうすれば座標を取得できますか? 座標から = [mapView convertPoint:touchLocation toCoordinateFromView:mapView];
?