I've been working on my map which gets it's details from a MySQL database. I use MarkerCluster Plus to cluster my markers but would like to add the drop animation to it.
I found this thread, but cannot get it to work with my database. Using Drop Markers and MarkerClusterer together?
Would anyone please be able to help me figuring out how to add the drop animation to my code? My test map is here: http://mymap.mooo.com
Really appreciate any help or pointers.
var customIcons = {
BOO: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png'
},
CIE: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_green.png'
}
};
var cluster =[];
var min = .999;
var max = 1.001;
function load() {
var map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(0,28.287167),
zoom: 3,
mapTypeId: 'roadmap'
});
var infoWindow = new google.maps.InfoWindow;
var mcOptions = {gridSize: 20, maxZoom: 19};
// this variable will collect the html which will eventually be placed in the side_bar
var side_bar_html = "";
// Change this depending on the name of your PHP file
downloadUrl("phpsqlajax_genxml2.php", 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("assetno");
var address = markers[i].getAttribute("address");
var type = markers[i].getAttribute("type");
var assetdesc = markers[i].getAttribute("assetdesc");
var location = markers[i].getAttribute("location");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat"))* (Math.random() * (max - min) + min) ,
parseFloat(markers[i].getAttribute("lng"))* (Math.random() * (max - min) + min));
var html = "<div style='font-family: Arial; font-size: 12px;'><b>" + name + "</b> <br/>" + assetdesc + "<br/>" + location + "</div>";
var icon = customIcons[type] || {};
setTimeout(function() {
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon,
animation: google.maps.Animation.DROP
});
return marker;
setTimeout(function () {
bindInfoWindow(marker, map, infoWindow, html);
cluster.push(marker);
// save the info we need to use later for the side_bar
// add a line to the side_bar html
side_bar_html += '<a href="javascript:myclick(' + (cluster.length-1) + ')">' + name + ' - ' + assetdesc +'<\/a><br>';
}, 1500);
}, i * 50);
}
var markerCluster = new MarkerClusterer(map, cluster, mcOptions);
// put the assembled side_bar_html contents into the side_bar div
document.getElementById("side_bar").innerHTML = side_bar_html;
});
}
// This function picks up the click and opens the corresponding info window
function myclick(i) {
google.maps.event.trigger(cluster[i], "click");
}
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() {}