google-places-api icon indicating copy to clipboard operation
google-places-api copied to clipboard

Nearby Search doesn't return all fields documented in official Google documentation

Open joldnl opened this issue 2 years ago • 1 comments

The nearbySearch method returns results, and I am able to retrieve them fine, but I wanted to use the address fields of the place documented in the Google Places API documentation for nearby search results.

But, among others address_components, adr_address, formatted_address. are missing in the results.

The only fields returned are:

  • business_status
  • geometry
  • icon
  • icon_background_color
  • icon_mask_base_uri
  • name
  • opening_hours
  • place_id
  • plus_code
  • rating
  • reference
  • scope
  • types
  • user_ratings_total
  • vicinity

I am doing the following:

$googlePlaces = new PlacesApi($this->api_key);

$params = [
    'keyword' => 'restaurant',
    'name' => null,
    'types' => null,
    'pagetoken' => $next_page_token
];

$response = $googlePlaces->nearbySearch($this->location, $this->radius, $params);
$results = $response->all()['results']->all();
var_dump($response);

Am I missing something? How can I get the address details of a place in the results of the nearby search? Of course I can do another api call and get those data but we're doing a large amount of queries so that would double our api usage.

joldnl avatar Mar 21 '22 20:03 joldnl

@joldnl if you check the same google documentation you mentioned, you will find the following.

Screenshot 2022-03-23 at 01 13 44 Screenshot 2022-03-23 at 01 13 51

Hope this helps

SachinAgarwal1337 avatar Mar 22 '22 19:03 SachinAgarwal1337