0
I am working on a web project that uses the maps api, however, in some moments, the system returns with the following error and the map did not open:
Uncaught Eb message: "initMap is not a Function"name: "Invalidvalueerror"stack: "Error at new Eb
At other times, the map opens normally. Does anyone have any idea what might be happening and how can I fix it? In my script there is no variable with the name Eb.
In HTML I define a div that will load the map
<div id="map" class="pull-right"></div>
So I import the map
<script src="https://maps.googleapis.com/maps/api/js?key=??????=places&callback=initMap"
async defer></script>
And I set the initMap function in a script on the same htlm page.
function initMap(){
// Definição do ponte de inicialização do mapa
var myLatLng = new google.maps.LatLng(-5.843470, -36.619855);
// Definição das configurações visuais do mapa
var mapOptions = {
zoom: 8,
center: myLatLng,
styles: [
{
featureType: 'road',
elementType: 'all',
stylers:[{visibility: 'off'}]
},
{
featureType: 'water',
elementType: 'all',
stylers:[{color: '#ffffff'}]
},
{
featureType: 'landscape',
elementType: 'all',
stylers:[{color: '#ffffff'}]
}
]
}
// Instanciando o mapa com as configurações defidas dentro de uma div cujo id está especificado na instrução
var map = new google.maps.Map(document.getElementById('map'),mapOptions);
var geocoder = new google.maps.Geocoder;
}
Within the script there are other definitions of variables and function. However, I only added this because it is the one that will initialize the map. Within the initMap function is also defined several polygons and the events of each Poligono.
Put the code there for us to help you, preferably your HTML and Javascript.
– Douglas Garrido
I added more information of the problem. Please take a look. Thank you.
– Talison Fernandes