#IntegrateGoogleMaps
Explore tagged Tumblr posts
codesolutionsstuff · 3 years ago
Text
How To Integrate Google Maps in Laravel
Tumblr media
A number of ways are available through the Google Maps JavaScript API to build maps for web applications. We will incorporate Google Maps into the Laravel project step-by-step in this tutorial.
Create a new Laravel project
composer create-project laravel/laravel laravel-google-maps
Create a view and add the following code
resources/views/map.blade.php
Laravel Google Maps
It's important to remember to change your Google API Key. Markers can be simply added and removed. Additionally, you can add more characteristics to the marker object based on your needs. - Add a marker const marker = new google.maps.Marker({ position: { lat: 28.625043, lng: 79.810135 }, label: { color: "white", text: "P4" }, draggable: true, map }); markers.push(marker); 2. Remove a marker Remove P4 marker const index = markers.findIndex(marker => marker.label.text == "P4"); if(index != -1) { markers.setMap(null); markers.splice(index, 1); } 3. Update marker properties Update P4 marker const index = markers.findIndex(marker => marker.label.text == "P4"); if(index != -1) { markers.setOptions({ ...markers, position: { lat: 28.625043, lng: 79.810135 } }); } Set marker properties using setOptions(options). Set the marker position using setPosition(latlng). Set a marker label with setLabel(label). show/hide a marker by using setVisible(boolean).
Create a controller and add the following code
php artisan make:controller MapController Read the full article
0 notes