在一些Goole maps JS上获取一系列错误,这将显示json文件中的一系列标记以及列表。地图会出现,并在所有标记和信息窗口打开时工作,但列表不会打开标记。我在WordPress中也遇到了一系列错误。我使用enque调用函数文件y=中的google map api。在纯html中,页面工作正常,没有错误。
我遇到的第一个错误是:
“initMap不是函数”名称:“InvalidValueError”堆栈:“Error”↵    在新kc(https://maps.googleapis.com/maps/api/js?key=MY-API-KEYk&callback=initMap&ver=4.7.4:47:499)↵    at对象。\\u。信用证proto:错误
    <script type="text/javascript">
        var map;
        var arrMarkers = [];
        var arrInfoWindows = [];
        function mapInit(){
            var centerCoord = new google.maps.LatLng(48.058249, -122.288615);
            var mapOptions = {
                zoom: 12,
                center: centerCoord,
                mapTypeId: google.maps.MapTypeId.TERRAIN
            };
            map = new google.maps.Map(document.getElementById("map"), mapOptions);
            $.getJSON("/wp-content/themes/the-language-of-puget-sound/js/map12.json", {}, function(data){
                $.each(data.places, function(i, item){
                $("#markers").append(\'<li><a href="#" rel="\' + i + \'">\' + item.English_Name + \'</a></li>\');
                var image = \'/wp-content/themes/the-language-of-puget-sound/js/Marker5-50.png\';
                var marker = new google.maps.Marker({
                     position: new google.maps.LatLng(item.Y_DD, item.X_DD),
                     map: map,
                     icon: image,
                     title: item.English_Name
                     });
                     arrMarkers[i] = marker;
                     var infowindow = new google.maps.InfoWindow({
                        content: "<span style=\'font-family: 
                        LushootseedSulad; font-size: large;\'>"+ item.Lushootseed +"</span><br><b>English Name: "+ item.English_Name +"</b><br>Meaning: "+ item.Meaning +"<br><img src="+ item.image +"><br>"+ item.Description +"<br><span style=\'font-family: LushootseedSulad; font-size: medium;\'>"+ item.Lushootseed +"</span><br><audio controls=\'true\' preload=\'none\' style=\'width:200px\'><br><source src=\'/wp-content/uploads/places/"+ item.audio +"\'\' type=\'audio/mpeg\'/>", border: 4, maxWidth: 250,
            });
            arrInfoWindows[i] = infowindow;
            google.maps.event.addListener(marker, \'click\', function() {
            var i = $(this).attr("rel");
            // this next line closes all open infowindows before opening the selected one
            for(x=0; x < arrInfoWindows.length; x++){ arrInfoWindows[x].close(); }  
            infowindow.open(map, marker);
                    });
               });
           });
        }
        $(function(){
        // initialize map (create markers, infowindows and list)
    mapInit();
        // "live" bind click event
        $("#markers a").live("click", function(){
             var i = $(this).attr("rel");
        // this next line closes all open infowindows before opening the selected one
        for(x=0; x < arrInfoWindows.length; x++){ arrInfoWindows[x].close(); 
    }
    arrInfoWindows[i].open(map, arrMarkers[i]);
            });
        });
    </script>