【问题标题】:CLPlacemark from Place could not map the selected Place来自 Place 的 CLPlacemark 无法映射选定的 Place
【发布时间】: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


【解决方案1】:

如果设置为SPPlaceTypeEstablishment,请将searchQuery.types更改为SPPlaceTypeGeocode

【讨论】:

  • 我已经解决了...... searchQuery.types 设置为 SPPlaceTypeEstablishment 是一个错误,我刚刚将其更改为 SPPlaceTypeGeocode,现在它正在工作
  • 好的,很高兴听到您的问题已得到解决 :)
  • 更新我在你的答案中写的内容,以便我可以将其标记为正确。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-27
  • 1970-01-01
  • 1970-01-01
  • 2022-01-10
相关资源
最近更新 更多