0

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?

zakharov.arthur
  • 187
  • 2
  • 13

1 Answers1

0

Instead of using function to create google map, you can use <iframe> for showing google map. For using <iframe> properly use you can visit to below link: https://en.support.wordpress.com/google-maps/

Suraj Libi
  • 515
  • 2
  • 9