MarkerClusterer没有标记集群 [英] MarkerClusterer not clustering markers
问题描述
我的地图是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())。
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屋!