I have an initial dropped pin in Map View.
What I want to accomplish is to drag that pin anywhere within the map and get the new coordinates from that pin. How to do that? What should I add?
I have this method where I do the initial drop pin.
- (void) performSearch
{
MKLocalSearchRequest *request =
[[MKLocalSearchRequest alloc] init];
request.naturalLanguageQuery = _searchString;
request.region = _mapView.region;
_matchingItems = [[NSMutableArray alloc] init];
MKLocalSearch *search =
[[MKLocalSearch alloc]initWithRequest:request];
[search startWithCompletionHandler:^(MKLocalSearchResponse
*response, NSError *error) {
if (response.mapItems.count == 0)
NSLog(@"No Matches");
else
for (MKMapItem *item in response.mapItems)
{
[_matchingItems addObject:item];
annotation = [[MKPointAnnotation alloc]init];
annotation.coordinate = item.placemark.coordinate;
annotation.title = item.name;
[_mapView addAnnotation:annotation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance (annotation.coordinate, 800, 800);
[_mapView setRegion:region animated:NO];
}
}];
}