Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue on Loading Google Map - SensorNotRequired

I am trying to run Google Map on a WordPress site. The code is running perfectly on this JSFIDDLE but when I take it to WordPress I am getting this error

Google Maps API warning: SensorNotRequired: https://developers.google.com/maps/documentation/javascript/error-messages

I also tried this code

<script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script>

but the result is same.

Finally I tried to get a key from API and use it

<script src="https://maps.googleapis.com/maps/api/js?key=xxxxxxxxxxxxxxxxxxxxxxxxxxx&callback=initMap"
    async defer></script>

and now I am getting this error

Uncaught TypeError: window.initMap is not a function

can you please let me know why this is happening and how I can fix it?

like image 575
Behseini Avatar asked Dec 10 '22 19:12

Behseini


1 Answers

Instead of:

<script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script>

Try:

<script language="javascript" src="https://maps.googleapis.com/maps/api/js?v=3"></script>

From the Google Maps API documentation:

The sensor parameter is no longer required for the Google Maps JavaScript API. It won't prevent the Google Maps JavaScript API from working correctly, but we recommend that you remove the sensor parameter from the script element.

like image 170
ScaisEdge Avatar answered Dec 24 '22 15:12

ScaisEdge