I am implementing Google Places API
, using auto complete I do get place id, now by using place id I want to find the location coordinate for that place. GMSPlace
doesn't return the geometry location. I searched but didn't get any help.
GMSPlacesClient *placeClient=[GMSPlacesClient sharedClient];
GMSAutocompleteFilter *filter = [[GMSAutocompleteFilter alloc] init];
filter.type = kGMSPlacesAutocompleteTypeFilterEstablishment;
[placeClient autocompleteQuery:str
bounds:nil
filter:filter
callback:^(NSArray *results, NSError *error) {
if (error != nil) {
NSLog(@"Autocomplete error %@", [error localizedDescription]);
return;
}
for (GMSAutocompletePrediction* result in results) {
//NSLog(@"Result '%@'", result.attributedFullText.string);
[placeName addObject:[NSString stringWithFormat:@"%@",result.attributedFullText.string]];
[placeID addObject:[NSString stringWithFormat:@"%@",result.placeID]];
}
NSLog(@"%@",placeName);
NSLog(@"%@",placeName);
}];
}
I think you can get place details by using place id like this
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);
}
}];
reference : here
You can get place detail from place id. check this Dock. This call will return GMSPlace. GSMPlace have property coordinate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With