简体   繁体   English

markercluster和google maps v3错误“a is undefined”

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

I'm struggling trying to cluster 50 markers using the markerclusterer v3 with Google maps API v3. 我正在努力尝试使用带有Google Maps API v3的markerclusterer v3来聚类50个标记。

I've followed the simple example found at: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/docs/examples.html to build my function however when the map is loaded I am getting the following error in firebug: 我已经按照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)

My function is just doing a simple json call to get the point from the server and then build the array of markers before adding them to the markerclusterer. 我的函数只是做一个简单的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);


        });


}

Any idea why this is causing the google map main.js to fail in this way? 知道为什么这会导致谷歌地图main.js以这种方式失败吗? If I just add the MarkerClusterer without the array of markers the map renders without errors. 如果我只添加没有标记数组的MarkerClusterer,则地图呈现时没有错误。

When I add the array of markers then the map errors. 当我添加标记数组时,地图错误。

Thanks, 谢谢,

Grant 格兰特

Fix was simple I'd miss out the fact that the google maps api v3 needs to have a object passed to it. 修复很简单我错过了谷歌地图api v3需要传递一个对象的事实。 The fix was to change 修复是改变

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