我使用SPGooglePlacesAutoComplete github库在iOS 7中为MapKit
实施谷歌地方自动完成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)"
答案 0 :(得分:0)
如果searchQuery.types
设置为SPPlaceTypeGeocode
,请将SPPlaceTypeEstablishment
更改为private void Answer_Checked(object sender, RoutedEventArgs e) // Radio button click
{
var radio = sender as RadioButton;
bool check = Convert.ToBoolean(radio.IsChecked);
if(check)
{
Answer[Convert.ToInt16(radio.GroupName)] = Convert.ToInt16(radio.Tag);
}
}
public async void Check_Result() // Evaluate result
{
foreach (KeyValuePair<int, int> count in Answer)
{
if (count.Value == 1)
{
result++;
}
}
MessageDialog showresult = new MessageDialog(result.ToString());
await showresult.ShowAsync();
Frame.Navigate(typeof(MainPage), null);
}
public void TestSubmit_Click(object sender, RoutedEventArgs e) // AppBar button click
{
Check_Result();
}
。