I have some markers on google maps and I would like to identify clusters by point-to-point distance between them. However, I am having a bit of difficulty:
First I loop through all the markers and create an array which is:
for (var i = 0; i < MARKERS.length - 1; i++) {
for (var j = i + 1; j < MARKERS.length; j++) {
var distance_between = google.maps.geometry.spherical.computeDistanceBetween(point_i, point_j)
var valueToPush = {}
valueToPush.fromMarker = name_i
valueToPush.toMarker = name_j
valueToPush.distance = distance_between
cluster_array.push(valueToPush)
}
}
What I would then like to do is run a hierarchical clustering algorithm like this:
var cluster = .cluster(cluster_array, MAX, threshold)
Where if I specify 500 for threshold then I get a list like this
Cluster 0: Marker A, Marker Y, Marker C
Cluster 1: Marker B
Cluster 2: Marker D, Marker E
etc.
Where each cluster shows me the markers that are within 500 metres of each other.
Thanks very much