Google Map Api Place Details
If you created an api request and get data about google map detail place, all you need to do is to send the request object to your controller method
public function place_api_details(Request $request)
{
$validator = Validator::make($request->all(), [
'placeid' => 'required',
]);
$response = Http::get('https://maps.googleapis.com/maps/api/place/details/json?placeid='.$request['placeid'].'&key='.'Your key');
return $response->json();
}
You see that we call Http::get() to call the google map api. That api needs your google map api key.
You should also get the placeid from request object.
Placeid, in general comes from Google prediction api.
Google Map Api AutoComplete
For auto complete the idea is, get the request object and inside the request object you will search text, this is the place that you are looking for.
public function place_api_autocomplete(Request $request)
{
$validator = Validator::make($request->all(), [
'search_text' => 'required',
]);
$response = Http::get('https://maps.googleapis.com/maps/api/place/autocomplete/json?input='.$request['search_text'].'&key='.'Your key');
return $response->json();
}
It also use Http::get() method to create a request with to google server.
Inside this Http::get() search_text refers to the text you are looking for. So each time, you search or type in something in the front end of Laravel application, it will make a request to the google server immediately and send us back a json response().
Learn how to use Laravel and Flutter Google Map Prediction