Laravel Google Autocomplete Address Example

By Hardik Savani April 16, 2024 Category : Laravel

Hi Dev,

Here, i will show you google autocomplete address in laravel. you can see google autocomplete address in laravel 8. you'll learn laravel google maps place autocomplete. This post will give you simple example of laravel google places autocomplete.

Sometime we need to use google map autocomplete api for getting correct address with latitude an longitude with laravel. i will help you step by step how to use google map api for autocomplete address in laravel app. you can use this example with laravel 6, laravel 7, laravel 8, laravel 9, laravel 10 and laravel 11 version as well.

you can see bellow preview, how it looks:


Step 1: Create Route

In this is step we need to create some routes for google autocomplete address example view.



use Illuminate\Support\Facades\Route;

use App\Http\Controllers\GoogleController;



| Web Routes



| Here is where you can register web routes for your application. These

| routes are loaded by the RouteServiceProvider within a group which

| contains the "web" middleware group. Now create something great!



Route::get('google-autocomplete', [GoogleController::class, 'index']);

Step 2: Create Controller

in this step, we need to create GoogleController and add following code on that file:



namespace App\Http\Controllers;

use Illuminate\Http\Request;

class GoogleController extends Controller



* Write code on Method


* @return response()


public function index()


return view('googleAutocomplete');



Step 3: Google Map API Key in Env

here, we will add new variable in .env file fo set google map api key. so let's add as bellow:



Step 4: Create Blade Files

here, we need to create blade files for google autocomplete example. so let's create one by one files:


<!DOCTYPE html>

<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">


<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Laravel Google Autocomplete Address Example</title>

<link rel="stylesheet" href="">

<script src=""></script>



<div class="container mt-5">

<h2>Laravel Google Autocomplete Address Example</h2>

<div class="form-group">


<input type="text" name="autocomplete" id="autocomplete" class="form-control" placeholder="Choose Location">


<div class="form-group" id="latitudeArea">


<input type="text" id="latitude" name="latitude" class="form-control">


<div class="form-group" id="longtitudeArea">


<input type="text" name="longitude" id="longitude" class="form-control">


<button type="submit" class="btn btn-primary">Submit</button>


<script src=""></script>

<script src=""></script>

<script type="text/javascript"

src="{{ env('GOOGLE_MAP_KEY') }}&libraries=places" ></script>


$(document).ready(function () {






google.maps.event.addDomListener(window, 'load', initialize);

function initialize() {

var input = document.getElementById('autocomplete');

var autocomplete = new google.maps.places.Autocomplete(input);

autocomplete.addListener('place_changed', function () {

var place = autocomplete.getPlace();










Now we are ready to run our example. so run bellow command so quick run:

php artisan serve

Now you can open bellow URL on your browser:


I hope it can help you...