1
我在地圖視圖中有一個初始放置的引腳。如何在mapview中拖動註釋引腳?
我想要完成的是在地圖上的任意位置拖動該針腳,並從該針腳獲取新的座標。怎麼做?我應該添加什麼?
我有這種方法,我做初始放置引腳。
- (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];
}
}];
}