I successfully configured MarkerClusterer v3 and Viewer Marker Management (making an ajax call to collect only the markers visible with the viewport and rendering them each time the map is "inactive") separately.
However, when I combine them, they only work together when the page first loads, not later.
When scaling or panning, the original clusters remain, and the markers for the entire map are displayed non-clustered, but the cluster markers remain earlier.
The original cluster markers still behave properly, although when zooming in / out, the new markers provided when changing the boundaries of the viewport are not added to them or are clustered.
Code below:
function drawMap(swLat, swLng, neLat, neLng){
$.ajax({
type: "POST",
url: "readMapInfo.php",
cache: false,
data:{S:swLat, W:swLng, N:neLat, E:neLng},
dataType: "xml",
success: function(data) {
if(markerArray.length >0){
for (i in markerArray) {
markerArray[i].setMap(null);
}
drawMarker(data);
mc = new MarkerClusterer(map, markerArray, clusterOptions);
} else {
drawMarker(data);
mc = new MarkerClusterer(map, markerArray, clusterOptions);
}
});
}
google.maps.event.addListener(map, 'idle', function() {
bounds = map.getBounds();
sw = bounds.getSouthWest();
ne = bounds.getNorthEast();
swLat = sw.lat();
swLng = sw.lng();
neLat = ne.lat();
neLng = ne.lng();
drawMap(swLat, swLng, neLat, neLng);
});