SachinAgarwal1337 / google-places-api

This is a PHP wrapper for Google Places API Web Service. And is Laravel Framework friendly.
MIT License
182 stars 44 forks source link

Insert more than 1 keyword in Search Nearby #68

Closed KautsarH closed 3 years ago

KautsarH commented 3 years ago

Hi, when I tried to insert more than one keywords ( making an array to the keyword), i didn't get the results that i wanted. It returned the keyword has no input. For example, I want to find nearest kfc and post office. But it returned all the nearest places without any specification.

$place = 'kfc'; $place2 = 'post office'; $keyword = array('keyword' => [$place,$place2]); $lat = "2.9960560"; $lng = "101.5755560"; $location = $lat. "," .$lng;

$response = GooglePlaces::nearbySearch($location, $radius,$keyword);

I already tried the method below, it works, but it consumes a lot of API request. so i want to prevent that method. $place = 'kfc'; $keyword = array('keyword' => $place); $place2 = 'pos laju'; $keyword2 = array('keyword' => $place2);

$response = GooglePlaces::nearbySearch($location, $radius,$keyword); response2 = GooglePlaces::nearbySearch($location, $radius,$keyword2); $result = $response["results"]->merge($response2["results"]);

SachinAgarwal1337 commented 3 years ago

@KautsarH Google API doesn't support multiple keywords. Have a look at this https://developers.google.com/maps/documentation/places/web-service/search#PlaceSearchRequests