Created
March 30, 2012 08:23
-
-
Save a1phanumeric/2249553 to your computer and use it in GitHub Desktop.
Convert MKMapView touch to coordinate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; | |
lpgr.minimumPressDuration = 1.0; | |
[self.mapView addGestureRecognizer:lpgr]; | |
// --------------------------------- | |
- (void)handleLongPress:(UIGestureRecognizer *)gestureRecognizer{ | |
if (gestureRecognizer.state != UIGestureRecognizerStateBegan)return; | |
CGPoint touchPoint = [gestureRecognizer locationInView:self.mapView]; | |
CLLocationCoordinate2D touchCoordinate = | |
[self.mapView convertPoint:touchPoint toCoordinateFromView:self.mapView]; | |
NSLog(@"%f, %f", touchCoordinate.latitude, touchCoordinate.longitude); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment