/*
 * jQuery UI MarkerMap MarkerClusterer plugin
 *
 * Author: Jannon Frank
 *
 * Depends:
 *  jquery.ui.markermap.js
 *  markerclusterer.js
 */

(function($) {
    $.ui.markermap.prototype.options.maxZoom = 5;
    $.ui.markermap.prototype.options.managers.clusterer = {
        create: function() {
            this.clusterer = new MarkerClusterer(this.map, [], {maxZoom: this.options.maxZoom});
        },
        addMarkers: function(markers) {
            if (this.clusterer) {
                this.clusterer.addMarkers(markers);
            }
        },
        clearMarkers: function() {
            if (this.clusterer) {
                this.clusterer.clearMarkers();
            }
        },
        destroy: function() {
            this.clusterer = null;
        },
        hideMarker: function(marker) {
            if (this.clusterer) {
                this.clusterer.removeMarker(marker);
            }
        },
        showMarker: function(marker) {
            if (this.clusterer) {
                this.clusterer.addMarker(marker);
            }
        }
    };
})(jQuery);

