Google is not defined - API google MAPS
Publié le .
[EN] If you use the Google Maps API, you have surely encountered this kind of problem, and by racking your brain over the official documentation, your error still does not resolve. The console responds "Uncaught ReferenceError: google is not defined". Here is the solution: You need to include google.maps.event.addDomListener(window,'load', initMap); in the API call script, where you enter your API key. [FR] Si vous utilisez l'API google maps, vous avez sûrement rencontré ce genre de problème, et en vous cassant la tête sur la documentation officielle, votre erreur ne se résout toujours pas. La console vous répond "Uncaught ReferenceError: google is not defined". Voici la solution: Il faut inclure google.maps.event.addDomListener(window,'load', initMap); dans le script d’appel à l'API, là ou vous entez votre clé D'API.
// the map container
<div id="map" style="width: 500px; height: 500px;"></div>
// Enter this code in the html page of the map
<script>
var myLatlng;
var map;
var mapOptions;
var infowindow;
function initMap() {
myLatlng = new google.maps.LatLng(44.36200,3.16700);
mapOptions = {
zoom: 13,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.HYBRID
};
infowindow = new google.maps.InfoWindow({
content: "I am HERE !",
position: myLatlng
});
infowindow.open(map);
map = new google.maps.Map(document.getElementById("map"), mapOptions);
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">google.maps.event.addDomListener(window,'load', initMap);</script>
Mots clés : Uncaught ReferenceError: google is not defined, API google MAPS, erreur api google maps, error api google maps, solve Uncaught ReferenceError: google is not defined, résoudre Uncaught ReferenceError: google is not defined, problème api google maps, erreur api google maps, error api google maps.