lipidfish
lipidfish

Reputation: 406

Location Specification with an iOS MapView

Using an iOS device, I am interested in tapping a mapview and getting back the lat / long coordinates of that spot. Is this possible?

Upvotes: 0

Views: 347

Answers (1)

Deepak Danduprolu
Deepak Danduprolu

Reputation: 44633

You can get the CLLocationCoordinate2D using convertPoint:toCoordinateFromView method of the MKMapView.

CLLocationCoordinate2D coordinate = [self.mapView convertPoint:[gesture locationInView:self.mapView] toCoordinateFromView:self.mapView];

I put this in a tap gesture handler to work. But if you are using some other mechanism to get the touch point, you can use the touch point as the argument passed in convertPoint:.

Upvotes: 2

Related Questions