Ok - so I tried out the other cluster plugin, but really didn't like it (not flexible enough).
I went back to the drawing board, and decided to take another look at this issue. I've FINALLY managed to find a solution (all be it a weird one)
The actual bug had something to do with the "id" param I was passing in. For some reason, the marker clusterer code is doing:
MarkerClusterer.prototype.addMarkers = function (markers, opt_nodraw) {
var i;
for (i = 0; i < markers.length; i++) {
this.pushMarkerTo_(markers[i]);
}
if (!opt_nodraw) {
this.redraw_();
}
};
To fix it, I just added in a basic if ()
statement, to make sure there is indeed a marker there
MarkerClusterer.prototype.addMarkers = function (markers, opt_nodraw) {
var i;
for (i = 0; i < markers.length; i++) {
if (markers[i] != undefined) {
this.pushMarkerTo_(markers[i]);
}
}
if (!opt_nodraw) {
this.redraw_();
}
};
Thats ok when you are NOT passing it as an array of IDs. When you are assigning an ID for each marker, it changes the format its saved in. The "fix" is to use the title
attribute for the marker instead - so:
jQuery('#map_inner').gmap('addMarker', {
'position': new google.maps.LatLng(marker.latitude, marker.longitude),
//'bounds': false,
'icon': './img/marker.png',
'title' : marker.linkid
}).click(function() {
// do stuff
});
Then if you need to grab the ID of the marker, you use the attr()
like so:
$(this).attr('title')
Its certainly not ideal, but it seems to work. There is obviously an inherent issue with using custom IDs to store the markers.
Hopefully this saves at least someone from all the headaches I got!