[Pkg-javascript-commits] [leaflet-markercluster] 163/479: Clean up adding markers to existing clusters with the new centering changes

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:25 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 a498cd47c25bca0ecac06dc6b0923464d36ea2c0
Author: danzel <danzel at localhost.geek.nz>
Date:   Mon Aug 13 10:09:44 2012 +1200

    Clean up adding markers to existing clusters with the new centering changes
---
 src/MarkerCluster.js | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js
index 23016fd..f900e72 100644
--- a/src/MarkerCluster.js
+++ b/src/MarkerCluster.js
@@ -77,12 +77,13 @@ L.MarkerCluster = L.Marker.extend({
 
 		if (!this._latlng) {
 			// when clustering, take position of the first point as the cluster center
-			this._latlng = addedLatLng;
+			this._latlng = this._cLatLng = addedLatLng;
 		}
 
 		// when showing clusters, take weighted average of all points as cluster center
 		var totalCount = this._childCount + addedCount;
 
+		//Calculate weighted latlng for display
 		if (!this._wLatLng) {
 			this._wLatLng = new L.LatLng(addedLatLng.lat, addedLatLng.lng);
 		} else {
@@ -204,7 +205,7 @@ L.MarkerCluster = L.Marker.extend({
 		}
 
 		var clusterRadiusSqrd = this._group.options.maxClusterRadius * this._group.options.maxClusterRadius,
-			pos = this._group._map.project(this._latlng, zoom),
+			pos = this._group._map.project(this._cLatLng, zoom),
 			otherpos = this._group._map.project(latlng, zoom);
 
 		return (this._group._sqDist(pos, otherpos) <= clusterRadiusSqrd);
@@ -469,7 +470,7 @@ L.MarkerCluster = L.Marker.extend({
 		if (this._childCount === 0) {
 			delete this._latlng;
 		} else {
-			this.setLatLng(this._bounds.getCenter());
+			this.setLatLng(this._wLatLng);
 		}
 	},
 

-- 
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