Clustering Module

Creates collapsible groups of Markers, Sprites or Images.

Example: Multi-Level Clustering

Usage

Load the file /modules/miniature.earth.clustering.js or copy the code to your script and customize it to your needs.

Methods

Earth.Clustering.enable( earth )

Enable clustering for this earth.

myearth.addEventListener( "ready", function() {

	Earth.Clustering.enable( this );

	/* add your objects and cluster them */

} );

EarthInstance.cluster( object, children )

object
(Marker/Sprite/Image) This object reveals its children on click (if hotspot: true).
If no location is given, the object is set to the average location of its children.
children
(array) An array of objects. These objects are collapsed and hidden by default.
var my_cluster_marker = myearth.addMarker( {
	mesh : "Pin3",
	hotspot : true
} );

var child1 = myearth.addMarker( {
	mesh : "Pin3",
	location : { lat: -25, lng: 14 },
	scale: 0.6
} );

var child2 = myearth.addMarker( {
	mesh : "Pin3",
	location : { lat: -21, lng: 10 },
	scale: 0.6
} );

myearth.cluster( my_cluster_marker, [child1, child2] );

EarthInstance.collapseAll()

Collapses all clusters.

myearth.collapseAll();
 

ObjectInstance.expand()

Shows the children of this cluster.

my_cluster_marker.expand();

ObjectInstance.collapse()

Hides the children of this cluster.

my_cluster_marker.collapse();