我正在通過使用SPGooglePlacesAutoComplete github庫實施谷歌地點自動完成API的MapKit
。 在仔細實施所有最後階段後,我想將我的Annotation
移動到用戶選定的位置,它會給出錯誤Domain=kCLErrorDomain Code=8
。
用戶從自動完成結果中選擇特定位置後會發生這種情況。所以這是我在做什麼,我didSelectRowAtIndexPath
方法:來自Place的CLPlacemark無法映射所選地點
[self.searchDisplayController setActive:NO animated:YES];
SPGooglePlacesAutocompletePlace *place = [placesArray objectAtIndex:indexPath.row];
[place resolveToPlacemark:^(CLPlacemark *placemark, NSString *addressString, NSError *error) {
if (error) {
SPPresentAlertViewWithErrorAndTitle(error, @"Could not map the selected Place");
}else if (placemark) {
[selectedPlaceAnnotation setCoordinate:placemark.location.coordinate];
locationLat = selectedPlaceAnnotation.coordinate.latitude;
locationLon = selectedPlaceAnnotation.coordinate.longitude;
[defaults setFloat:locationLat forKey:@"locLat"];
[defaults setFloat:locationLon forKey:@"locLon"];
selectedPlaceAnnotation.title = @"You Selected This Location";
if (![self.MapView.annotations containsObject:selectedPlaceAnnotation]==YES) {
[self.MapView addAnnotation:selectedPlaceAnnotation];
}
//[self.MapView animateToLocation:placemark.location.coordinate];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(placemark.location.coordinate, 800, 800);
[self.MapView setRegion:[self.MapView regionThatFits:region] animated:YES];
[self.searchDisplayController.searchResultsTableView deselectRowAtIndexPath:indexPath animated:NO];
}
}
];
如果我打印resolveToPlacemark
參數我得到這個Placemark = (null) Address String = (null) Error = Error Domain=kCLErrorDomain Code=8 "(null)"
你可以請檢查對象的地方? –
@ VishnuKumar.S位置對象正在打印從搜索結果中選擇的正確值。 –