Sau*_*dey 0 google-maps autocomplete objective-c
我正在使用谷歌自动完成API,我得到了地名和placeid,但我无法得到该地方的合作伙伴.先生,我怎样才能找到坐标.
 GMSAutocompleteFilter *filter = [[GMSAutocompleteFilter alloc] init];
    filter.type = kGMSPlacesAutocompleteTypeFilterCity;
    [_placesClient autocompleteQuery:@"s"//this should be your textfield text
                              bounds:nil
                              filter:filter
                            callback:^(NSArray *results, NSError *error) {
                                if (error != nil) {
                                    NSLog(@"Autocomplete error %@", [error localizedDescription]);
                                    return;
                                }
                                for (GMSAutocompletePrediction* result in results) {
                                    NSDictionary *aTempDict =  [NSDictionary dictionaryWithObjectsAndKeys:result.attributedFullText.string,@"description",result.placeID,@"reference", nil];
                                    PlaceObject *placeObj=[[PlaceObject alloc]initWithPlaceName:[aTempDict objectForKey:@"description"]];
                                    placeObj.userInfo=aTempDict;
                                    //                                    [finalarray addObject:placeObj];
                                    NSLog(@"Result '%@' with placeID %@", result.attributedFullText.string, result.placeID);
                                    NSLog(@"%@",finalarray);
                                    [finalarray addObject:result.attributedFullText.string];
                                    NSString *aStrPlaceReferance=[placeObj.userInfo objectForKey:@"reference"];
                                          NSLog(@"%@",aStrPlaceReferance);
                                    NSString *aStrPlaceReferance1=[placeObj.userInfo objectForKey:@"description"];
                                    NSLog(@"%@",aStrPlaceReferance1);
                                }
                            }];
我从来没有使用过这个API,但是从文档中看起来你应该使用placeID每个GMSAutocompletePrediction对象的属性并发出新的请求以获取所需的信息.
根据本指南,你需要这样打电话GMSPlacesClient lookUpPlaceID:callback::
// A hotel in Saigon with an attribution.
NSString *placeID = @"ChIJV4k8_9UodTERU5KXbkYpSYs";
[_placesClient lookUpPlaceID:placeID callback:^(GMSPlace *place, NSError *error) {
  if (error != nil) {
    NSLog(@"Place Details error %@", [error localizedDescription]);
    return;
  }
  if (place != nil) {
    NSLog(@"Place name %@", place.name);
    NSLog(@"Place address %@", place.formattedAddress);
    NSLog(@"Place placeID %@", place.placeID);
    NSLog(@"Place attributions %@", place.attributions);
  } else {
    NSLog(@"No place details for %@", placeID);
  }
}];
然后使用该place.coordinate属性.
| 归档时间: | 
 | 
| 查看次数: | 762 次 | 
| 最近记录: |