Skip to content

Instantly share code, notes, and snippets.

@pablinhob
Last active August 29, 2015 13:55
Show Gist options
  • Save pablinhob/8756527 to your computer and use it in GitHub Desktop.
Save pablinhob/8756527 to your computer and use it in GitHub Desktop.
function create_clusters() {
while(x) {
this.point_clusters[x] = consulta_arbol_r_x();
for (var i=0; point_clusters.lenght <= i; i++) {
point_clusters[x] = create_clusters_clean(
this.point_clusters[x]
create_clusters_order(this.point_clusters[x]),
i
);
}
}
// xa fora do bucle de zooms
refresh_markers();
}
function create_clusters_clean( all_clusters, clusters_by_size, recursion_num ) {
var result_array = [];
var current_cluster = [];
$( clusters_by_size ).each( function(i,e) {
// fisrt (recursion_num) elements are ready
if( i<= recursion_num ) {
result_array[e] = all_clusters[e];
all_clusters[e].remove();
// load current node to compare with next others
if( i == recursion_num ) {
current_cluster = all_clusters[e];
}
}
else { // now, search for duplicates in the rest of items
$(current_cluster).each( function(i2,current_cluster_val) {
if(current_cluster_val == e){ //looking for duplicated 1st dimension keys.
all_clusters[e].remove();
}
else { //looking for duplicated 2st dimension keys
$(all_clusters[e]).each( function(i3, iteration_cluster_2st_val){
if(iteration_cluster_2st_val == current_cluster_val) {
all_clusters[e][i3].remove();
}
});
}
});
}
});
result_array.push(all_clusters)
return result_array;
}
function create_clusters_order(point_clusters){
var ord_array = [];
var largest_index = false;
var largest_value = 0;
do {
largest_value = 0;
$(point_clusters ).each(i,e) {
if( $(point_clusters).lenght > largest_value ) {
largest_value = $(point_clusters).lenght;
largest_index = i;
}
}
ord_array.push(largest_index);
point_clusters[largest_index].remove();
} while( $(point_clusters).lenght > 0);
return ord_array;
}
/*
Establecemos de cero os markers e os clustermarkers se non existen
poñendo máximo e minimo zoom permitido nos rangos e sempre invisibles
posteriormente e despois de cada debuxado de filtro, collemos e imos
acotando por encima máis por debaixo;
*/
function refresh_markers() {
//
// Establecer zooms de novo
// Visibilidade null para todos
// Reiniciar zoom mínimo a zoom máximo
//
for (var zoomlevel = 0; zoomlevel <= maxzoom; zoomlevel++) {
$(this.point_clusters[zoomlevel]).each(function(i, cluster){
if( $(cluster).lenght == 1 ) {
// parámetros por extender
this.markers[i].zoom_minimo = zoomlevel;
this.markers[i].visible = true;
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment