Marker Clusterer谷歌地图

时间:2011-09-14 14:07:43

标签: javascript google-maps markerclusterer

HY,

我不知道为什么标记聚类器不会显示我的标记分组,例如:http://media.svennerberg.com/2009/01/screenshot_clusterereffect.jpg

我的代码是这样的:

    <!DOCTYPE html>
<html>
<head>
<script type="text/javascript"
    src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">

 function initialize() {
        var center = new google.maps.LatLng(48.136, 11.586);

        var myOptions = {
          zoom: 3,
          center: center,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions); 

        var points =  []; 
        for (var i = 0; i < 600; i++) {

                var point = new google.maps.Marker({
                    position: new google.maps.LatLng(48.135 + Math.random(), 11.664 + Math.random()),
                    map: map,
                    title:"This is where I work"
                }); 
                points.push(point);

        }

        var cluster = new MarkerClusterer(map, points);
    }

</script>
</head>
<body onload="initialize()">
  <div id="map_canvas" style="width:1000px; height:1000px"></div>
</body>
</html>

但它不起作用。谁可以告诉我为什么它不起作用? THX

1 个答案:

答案 0 :(得分:0)

问题解决了:)我的html文件没有加载正确的json,这就是为什么它没有成功