Need your help. I have the error on my WordPress site. Google Maps shows this errors:
Jb {message: "initMap is not a function", name: "InvalidValueError", stack: "Error↵ at new Jb (https://maps.googleapis.com/m…xALxizYJSGZA470&callback=initMap&ver=4.9.5:157:51"}
And this
Uncaught TypeError: Cannot read property 'firstChild' of null
In my code.js I have this code:
(function ($) {
...
function initMap(officeLocation, pathMap) {
var map = new google.maps.Map(document.getElementById(pathMap), {
zoom: 15,
center: officeLocation
});
var marker = new google.maps.Marker({
position: officeLocation,
map: map
});
}
showOnKyivMap.on('click', function() {
mapCover.fadeIn(500);
initMap(kyivOffice, mapFooter);
});
$(document).ready(function() {
initMap(kyivOffice, mapKyivContacts);
});
})(jQuery);
Google Map script is connected in functions.php
wp_enqueue_script( 'google-maps', "https://maps.googleapis.com/maps/api/js?key=AIzaSyAN-c6nn0xMNJB_2SfGxALxizYJSGZA470&callback=initMap", array("code-js"), '', true);
So what do I do wrong?