MarkerClusterer没有标记集群 [英] MarkerClusterer not clustering markers

查看:121
本文介绍了MarkerClusterer没有标记集群的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的地图是pretty低迷,由于大量的存储位置的数据/标记,所以我就先markerclusterer工作显示<一个href=\"http://google-maps-utility-library-v3.google$c$c.com/svn/trunk/markerclusterer/docs/examples.html\"相对=nofollow>此处。位置仅仅是一个C#字符串数组,具有名称,纬度和每个标记经度。
出于某种原因,图仍然有效,只是显示个人标记,并且不聚集他们,我想不通为什么。任何帮助将是AP preciated。

 &LT;脚本类型=文/ JavaScript的&GT;    无功位置=并[d(%)=地点%]的计算值;    VAR地图=新google.maps.Map(的document.getElementById('地图'){
        变焦:10,
        中心:新google.maps.LatLng(30.2979536,-97.7470835)
        mapTypeId设为:google.maps.MapTypeId.ROADMAP
    });    变种标记= [];    对于(VAR I = 0; I&LT; locations.length;我++){
        VAR的标记=新google.maps.Marker({位置:新google.maps.LatLng(位置[I] [1],位置[I] [2]),地图:地图});
        markers.push(标记);
    }  VAR markerCluster =新MarkerClusterer(标记);
&LT; / SCRIPT&GT;


解决方案

  • 删除地图:地图在您添加标记的选项。

  • 地图传递到MarkerClusterer

      VAR markerCluster =新MarkerClusterer(地图,标记);


您可能想的纬度和经度浮点数转换字符串(与parseFloat())。

工作的例子有MarkerClusterer

My map is pretty sluggish due to the large amount of data/markers stored in locations so I tried to get markerclusterer working shown here. Locations is just a c# string array that has a name, latitude, and longitude for each marker. For some reason the map still works but just shows individual markers and does not cluster them and I cannot figure out why. Any help would be appreciated.

<script type="text/javascript">

    var locations = [<%=locations%>];

    var map = new google.maps.Map(document.getElementById('map'), {
        zoom: 10,
        center: new google.maps.LatLng(30.2979536, -97.7470835),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var markers = [];

    for (var i = 0; i < locations.length; i++) {
        var marker = new google.maps.Marker({position: new  google.maps.LatLng(locations[i][1], locations[i][2]), map: map });
        markers.push(marker);
    }

  var markerCluster = new MarkerClusterer(markers);
</script>

解决方案

  • remove map: map from the options in the markers you add.
  • pass the map into the MarkerClusterer

    var markerCluster = new MarkerClusterer(map, markers);
    

You might want to convert the latitude and longitude to floating point numbers from strings (with parseFloat()).

working example with MarkerClusterer

这篇关于MarkerClusterer没有标记集群的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆