tisuchi
tisuchi

Reputation: 954

Google Map Autocomplete with Laravel

Trying to add google autocomplete in Laravel. My code is like follows-

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<script type="text/javascript">
    google.maps.event.addDomListener(window, 'load', function () {
        var places = new google.maps.places.Autocomplete(document.getElementById('txtPlaces'));
        google.maps.event.addListener(places, 'place_changed', function () {

        });
    });
</script>
<span>Location:</span>
<input type="text" id="txtPlaces" style="width: 250px" placeholder="Enter a location" />

Its absolutely works in HTML / PHP file. The output in html/php file is like that-

enter image description here

However, when I wanna implement in Laravel, its not working at all. It shows the following error. enter image description here

Can you help me to fixed this one?

Upvotes: 3

Views: 10654

Answers (1)

Dhara Parmar
Dhara Parmar

Reputation: 8101

You need to add key in url, the reason of this error is that you haven't configured your Google Maps API keys yet.

Refer to see - How to create key: http://docs.gravityview.co/article/306-signing-up-for-a-google-maps-api-key

Add key to url:

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR API KEY&libraries=places"></script>

or use this url:

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>

Upvotes: 5

Related Questions