我在googlemaps API中使用群集。它工作正常。现在我在同一个位置有一些标记(1个建筑物中的更多活动)。所以我确实抵消了标记。但是如果我点击群集,那么它经常会找到一个新的群集。并且该群集无法打开。这是一些重要的代码:
var mc;
var markerCluster = {gridSize: 27, maxZoom: 15};
.
.
.
.
//OFFSET BEPALEN
var min = .999999;
var max = 1.000001;
var matA = (Math.random() * (max - min) + min);
var matB = (Math.random() * (max - min) + min);
var offsetLat = post_lat[i] * matA;
var offsetLng = post_lon[i] * matB;
//POSITIE BEPALEN MARKERS
var point = new google.maps.LatLng(offsetLat, offsetLng);
var icon = customIcons[5] || {};
marker = new google.maps.Marker({
icon: icon.icon,
position: point,
map: map,
zIndex: 9999999
});
infowindow.open(map, marker);
}
})(marker, i));
cluster.push(marker);
}
}
var mc = new MarkerClusterer(map, cluster,
{imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
document.getElementById("info").innerHTML = "ACTIVITEITEN : "+activ;
}
This is the Demo: (click at '2 weken').
https://www.pctraverse.nl/Project/geoB.php
似乎必须有一分钟。标记之间的距离。随机而言,并非总是如此。所以我用一个min的代码替换了randomize。标记之间的lat和lng之间的距离为0.000013。