こんにちは、Googleマップにmarkerclustererを追加しようとしていますが、マーカーはマップ上にありますが、クラスターが表示されないため、確かに何かが欠けています...
ここに私のスクリプトがあります:
//<![CDATA[
function initialize() {
var cluster = [];
var map = new google.maps.Map(document.getElementById("map_canvas"), {
center: new google.maps.LatLng(<?php echo get_post_meta($find_CODGEO, 'latitude', true); ?>, <?php echo get_post_meta($find_CODGEO, 'longitude', true); ?>),
zoom: 14,
mapTypeId: 'roadmap'
});
var mcOptions = {gridSize: 10, maxZoom: 15};
var infoWindow = new google.maps.InfoWindow;
downloadUrl("/wp-content/themes/codium-extend/search/search_equipements.php?lat=<?php echo get_post_meta($find_CODGEO, 'latitude', true); ?>&lng=<?php echo get_post_meta($find_CODGEO, 'longitude', true); ?>&type=<?php echo $thematiquematch ; ?>&codgeo=<?php echo $CODGEO ; ?>&radius=50", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("sous_type");
var type = markers[i].getAttribute("sous_type_img");
var offsetLat = markers[i].getAttribute("lat");
var offsetLng = markers[i].getAttribute("lng");
var point = new google.maps.LatLng(offsetLat, offsetLng);
var html = "<b>" + name + "</b> <br/>" + address;
var icon = 'http://images.commune-mairie.fr/maps/' + type + '.png';
var marker = new google.maps.Marker({
map: map,
position: point,
icon: 'http://images.commune-mairie.fr/maps/' + type + '.png',
shadow: icon.shadow
});
bindInfoWindow(marker, map, infoWindow, html);
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(markers[i].getAttribute("name"));
infowindow.open(map, marker);
}
})(marker, i));
cluster.push(marker);
}
var mc = new MarkerClusterer(map,cluster,mcOptions);
});
}
function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
}
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
function doNothing() {}
//]]>
ここに実例があります http://www.commune-mairie.fr/equipements/lyon-69123/ご協力ありがとうございます!