Google Map
Laravel - Multiple Markers In Google Map Using Gmaps.js
Today, we learn how to implement google map with multiple marker using gmaps.js library in laravel 5, laravel 6, laravel 7, laravel 8 and laravel 9. We can also simply use google map API for maps, But gmaps.js is very popular and they provides very simple way to generate google map.
- TAGS
- Laravel
- Google Map
- Google API
- 4.5/5.0
- Last updated 08 September, 2022
- By Admin
gmaps.js through we can make multiple markers, make routes, Geocoding, Map events etc. In this example i use multiple markers example.
If you are beginner then also you can do it simply following post, i did this example from scratch.
So, After finish all tutorial you will find layout as bellow.
Ok, so first we have a one table "location" with bellow structure and data.
location table:
After this we have to add one route for our example, so if you have laravel 5 then open route file and add bellow route.
routes/web.php
Route::get('gmaps', 'HomeController@gmaps');
Ok, now we have to make "gmaps" method on "HomeController". So, first if you haven't created HomeController then first create HomeController and put bellow code
app/Http/Controllers/HomeController.php
namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Requests; use DB; class HomeController extends Controller { public function gmaps() { $locations = DB::table('locations')->get(); return view('gmaps',compact('locations')); } }
At Last we have to create gmaps.blade.php file on resources folder, so create view file and put bellow code:
resources/views/gmaps.blade.php
Laravel 5 - Multiple markers in google map using gmaps.js Laravel 5 - Multiple markers in google map using gmaps.js
I hope it can help you...