【发布时间】:2016-07-26 17:59:00
【问题描述】:
我正在使用SPGooglePlacesAutoComplete github 库在iOS 7 中为MapKit 实现google Places 自动完成API。
在仔细实施一切后,我想将我的Annotation 移动到用户选择的位置的最后阶段,它给出了错误Domain=kCLErrorDomain Code=8。
这发生在用户从自动完成结果中选择特定位置之后。所以这就是我在didSelectRowAtIndexPath 方法中所做的:
[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 地点对象正在打印我从搜索结果中选择的正确值。
标签: ios objective-c autocomplete google-places-api