[英]Google map clustering with batch wise data issue with zoom in or out time
//This is the code//
var mapDiv = document.getElementById('newmap');
map = new google.maps.Map(mapDiv, {
center: new google.maps.LatLng(latitude, longitude),
zoom: zoom,
panControl: true,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
},
zoomControl: true,
zoomControlOptions:
{
position: google.maps.ControlPosition.LEFT_TOP,
},
streetViewControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var new_arr=new Array();
function addMarker1(locations,outletname,outletData)
{
var markers1 = locations.map(function(location, i)
{
return new google.maps.Marker
({
position: location,
});
});
var markerCluster = new MarkerClusterer(map, new_arr,{imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
new_arr=new_arr.concat(markers1);
markerCluster.resetViewport();
markerCluster.clearMarkers();
markers = [];
markerCluster.removeMarker(new_arr);
markerCluster.addMarkers(new_arr);
markerCluster.redraw();
}
// this is sending location in patches of 10000 each//
addMarker1(j,outletname,outletData);
需要渲染的总数据为100000。我以10000的补丁发送数据,并对其进行汇总以显示最终正常工作的100000个标记的单个群集。 但是在放大后,当我单击缩小时,它会在每个zoom_changed事件上再次形成每个10000的补丁,并通过形成每个10000的簇而不是形成一个单独的簇来重叠。
解决方案是在遍历标记之前清除数据
if (markerCluster)
{
markerCluster.clearMarkers();
markerCluster.resetViewport();
markers = [];
markerCluster.removeMarker(new_arr);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.