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
Can't believe I didn't think of this sooner!!
It just a case of building the string in the listener.
// Change this depending on the name of your PHP file
downloadUrl("/phpsqlajax_genxml.php ", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
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 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() {
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var html = "" + name + "
" + address;
infowindow.setContent(html);
infowindow.open(map, marker, html);
// infowindow.setContent(html);
// infowindow.open(map, marker);
}
})(marker, i));
cluster.push(marker);
}