簡體   English   中英

markercluster和google maps v3錯誤“a is undefined”

[英]markercluster and google maps v3 error “a is undefined”

我正在努力嘗試使用帶有Google Maps API v3的markerclusterer v3來聚類50個標記。

我已經按照http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/docs/examples.html上的簡單示例來構建我的函數,但是當加載地圖時我我在firebug中收到以下錯誤:

a is undefined
Ba(H,function(a){if(!a)return l;return...){return new P(this.T.d,this.P.b,i)}; main.js (line 13)

我的函數只是做一個簡單的json調用來從服務器獲取點,然后在將它們添加到markerclusterer之前構建標記數組。

function addMarkerCluster(){
    //get json data and create array of map markers and mark up the map using
    //a map cluster

    $.getJSON("feed/kml.php?action=json",
        function(data){

            var map;
            var markers = [];

            var latlng = new google.maps.LatLng(24.91654, 15.31326);

            var myOptions = {
                zoom: 3,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.HYBRID

            };
            map = new google.maps.Map(document.getElementById("googlemap"), myOptions);

            google.maps.event.addListener(map, "tilesloaded", function(){
                attachFancyBox();
                hideLoadDialog();
            });


            //loop through the data and add to the markers array the lat/lng of the centerpoints
            //as google lat/lng objects.
            $.each(data, function(i){

                latlng = new google.maps.LatLng(this.lat, this.lng);
                var marker = new google.maps.Marker(latlng);

                markers.push(marker);

            });



            var markerCluster = new MarkerClusterer(map, markers);


        });


}

知道為什么這會導致谷歌地圖main.js以這種方式失敗嗎? 如果我只添加沒有標記數組的MarkerClusterer,則地圖呈現時沒有錯誤。

當我添加標記數組時,地圖錯誤。

謝謝,

格蘭特

修復很簡單我錯過了谷歌地圖api v3需要傳遞一個對象的事實。 修復是改變

var marker = new google.maps.Marker(latlng) 
to
var marker = new google.maps.Marker({'position' : latlng});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM