[Pkg-javascript-commits] [leaflet-markercluster] 56/479: Get addLayer after clustering going. _recursivelyAddChildMarker still has some TODOs that need doing

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:09 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository leaflet-markercluster.

commit f5cac38268fe1f08592375e0e2251e64d477b366
Author: danzel <danzel at localhost.geek.nz>
Date:   Fri Jul 20 09:58:31 2012 +1200

    Get addLayer after clustering going. _recursivelyAddChildMarker still has some TODOs that need doing
---
 src/MarkerClusterGroup.js | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 8ca90be..bde6b9f 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -92,7 +92,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 	_generateInitialClusters: function () {
 		console.log('generating initial topCluster ' + this._map.getZoom());
-		var res = this._topClusterLevel = this._clusterToMarkerCluster([], [], this._needsClustering, this._map.getZoom());
+		var res = this._topClusterLevel = this._clusterToMarkerCluster([], [], this._needsClustering, this._map.getZoom(), false);
 
 		//Remember the current zoom level and bounds
 		this._zoom = this._map._zoom;
@@ -116,8 +116,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 			//Ensure all of the intermediate zoom levels are generated, generating up happens outside of MarkerCluster
 			while (this._topClusterLevel._zoom > this._map._zoom) {
 				console.log('generating new topCluster for ' + (this._topClusterLevel._zoom - 1));
-				this._topClusterLevel = this._clusterToMarkerCluster([], [], this._topClusterLevel._childClusters.concat(this._topClusterLevel._markers), this._topClusterLevel._zoom - 1);
-				this._topClusterLevel = this._clusterToMarkerCluster([], [], this._topClusterLevel._childClusters.concat(this._topClusterLevel._markers), this._topClusterLevel._zoom - 1);
+				this._topClusterLevel = this._clusterToMarkerCluster([], [], this._topClusterLevel._childClusters.concat(this._topClusterLevel._markers), this._topClusterLevel._zoom - 1, true);
 			}
 
 			this._animationZoomOut(this._zoom, this._map._zoom);
@@ -222,8 +221,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 	//Takes a list of objects that have a 'getLatLng()' function (Marker / MarkerCluster)
 	//Performs clustering on them (using a greedy algorithm) and returns those clusters.
-	//Returns a L.MarkerCluster with _zoom set
-	_cluster: function (existingClusters, existingUnclustered, toCluster, zoom) {
+	//hasChildClusters: True if these clusters are the parent of another level of clusters (false if this is the first level generated)
+	//Returns FIXME TODO
+	_cluster: function (existingClusters, existingUnclustered, toCluster, zoom, hasChildClusters) {
 		var clusterRadiusSqrd = this.options.maxClusterRadius * this.options.maxClusterRadius,
 		    clusters = existingClusters,
 		    unclustered = existingUnclustered,
@@ -268,6 +268,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 					if (this._sqDist(point._projCenter, unclustered[j]._projCenter) <= clusterRadiusSqrd) {
 						//Create a new cluster with these 2
 						var newCluster = new L.MarkerCluster(this, point, unclustered[j]);
+						newCluster._haveGeneratedChildClusters = hasChildClusters;
 						clusters.push(newCluster);
 
 						newCluster._projCenter = this._map.project(newCluster.getLatLng(), zoom);
@@ -305,8 +306,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 	},
 
 	//Clusters the given markers (with _cluster) and returns the result as a MarkerCluster
-	_clusterToMarkerCluster: function (existingClusters, existingUnclustered, toCluster, zoom) {
-		var res = this._cluster(existingClusters, existingUnclustered, toCluster, zoom),
+	_clusterToMarkerCluster: function (existingClusters, existingUnclustered, toCluster, zoom, hasChildClusters) {
+		var res = this._cluster(existingClusters, existingUnclustered, toCluster, zoom, hasChildClusters),
 			toAdd = res.clusters.concat(res.unclustered),
 			result = new L.MarkerCluster(this, toAdd[0]),
 			i;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet-markercluster.git



More information about the Pkg-javascript-commits mailing list