I\'ve followed this tutorial to create a custom Google Map. I\'ve included a few other elements such as linking it up to Wordpress and clustering the markers.
It\'s
If I'm reading it correctly. You are trying to set content 'after' setting the marker.
This should be the other way around. Move the piece where you set the html to before you push it to the cluster.
edit:
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var type = markers[i].getAttribute("type");
var offsetLat = markers[i].getAttribute("lat") * (Math.random() * (max - min) + min);
var offsetLng = markers[i].getAttribute("lng") * (Math.random() * (max - min) + min);
var point = new google.maps.LatLng(offsetLat, offsetLng);
//var html = "" + name + "
" + address;
var infowindow = new google.maps.InfoWindow({content: "" + name + "
" + address});
var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon,
shadow: icon.shadow
});
//google.maps.event.addListener(marker, 'click', (function(marker, i) {
// return function() {
// infowindow.setContent(markers[i].getAttribute("name"));
// infowindow.open(map, marker, html);
// }
// })(marker, i));
google.maps.event.addListener(marker, 'click', function(marker, i){infowindow.open(map,marker);})(marker, i);
cluster.push(marker);
}
Not sure about the (marker, i) pieces. I assume they are used by the marker manager to keep trakc of what's what. Those two changes (I commented out your lines and added one below) seem to be the next logical step.