1
如何獲取用戶在mapView上做長房(如2s)的經度和緯度。通過地圖查看姿勢獲取座標
我遇到了類似的問題:get coordinates on tap in iphone application
但我不明白我怎麼去有關的MapView處理觸摸事件。
我想要實現它以將針註釋放到位置,通過Google API執行內容反向地理編碼並將其顯示在字幕上。所以首先,我需要獲得所需的座標。
例子將非常感激。
謝謝。
如何獲取用戶在mapView上做長房(如2s)的經度和緯度。通過地圖查看姿勢獲取座標
我遇到了類似的問題:get coordinates on tap in iphone application
但我不明白我怎麼去有關的MapView處理觸摸事件。
我想要實現它以將針註釋放到位置,通過Google API執行內容反向地理編碼並將其顯示在字幕上。所以首先,我需要獲得所需的座標。
例子將非常感激。
謝謝。
您可以轉換在從手勢到檢索GPS視圖觸摸的座標座標是這樣的...
- (void)mapLongPress:(UILongPressGestureRecognizer *)gestureRecognizer{
if(gestureRecognizer.state == UIGestureRecognizerStateBegan){
CGPoint touchLocation = [gestureRecognizer locationInView:mapView];
CLLocationCoordinate2D coordinate;
coordinate = [mapView convertPoint:touchLocation toCoordinateFromView:mapView];
}
}
注意,在我的例子,我已申請的MapView本身的姿態。你將不得不通過你應用手勢的視圖到toCoordinateFromView:mapView
太棒了。只需在viewDidLoad中添加以下內容UILongPressGestureRecognizer * longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(mapLongPress :)]; \t longPressGesture.minimumPressDuration = 2; \t [mapView addGestureRecognizer:longPressGesture]; \t [longPressGesture發佈]; –