[Pkg-javascript-commits] [leaflet-markercluster] 167/479: Update build

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:26 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 834e9023e5df8836c3f0fea3eb2abd45ed4bfd50
Author: danzel <danzel at localhost.geek.nz>
Date:   Mon Aug 13 10:40:04 2012 +1200

    Update build
---
 dist/leaflet.markercluster-src.js | 28 +++++++++++++++++-----------
 dist/leaflet.markercluster.js     |  2 +-
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/dist/leaflet.markercluster-src.js b/dist/leaflet.markercluster-src.js
index abddbcb..c83c283 100644
--- a/dist/leaflet.markercluster-src.js
+++ b/dist/leaflet.markercluster-src.js
@@ -13,7 +13,7 @@
 L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 	options: {
-		maxClusterRadius: 60, //A cluster will cover at most this many pixels from its center
+		maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center
 		iconCreateFunction: null,
 
 		spiderfyOnMaxZoom: true,
@@ -299,7 +299,6 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 			if (cluster) {
 				cluster._addChild(marker);
-				clusters.updateObject(cluster, this._map.project(cluster.getLatLng(), zoom));
 			} else {
 				// otherwise, look through all of the markers we haven't managed to cluster and see if we should form a cluster with them
 				newCluster = this._clusterOne(unclustered, marker, markerPoint);
@@ -326,6 +325,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 				return true;
 			}
+			return false;
 		});
 
 		unclustered.eachObject(function (marker) {
@@ -582,6 +582,7 @@ L.MarkerCluster = L.Marker.extend({
 	},
 
 	_baseInit: function () {
+		this._latlng = this._wLatLng;
 		L.Marker.prototype.initialize.call(this, this._latlng, { icon: this._group.options.iconCreateFunction(this._childCount) });
 	},
 
@@ -604,25 +605,30 @@ L.MarkerCluster = L.Marker.extend({
 	_expandBounds: function (marker) {
 
 		var addedCount,
-		    addedLatLng;
+		    addedLatLng = marker._latlng;
 
 		if (marker instanceof L.MarkerCluster) {
 			this._bounds.extend(marker._bounds);
 			addedCount = marker._childCount;
-			addedLatLng = marker._latlng;
 		} else {
-			addedLatLng = marker.getLatLng();
 			this._bounds.extend(addedLatLng);
 			addedCount = 1;
 		}
 
+		if (!this._latlng) {
+			// when clustering, take position of the first point as the cluster center
+			this._latlng = this._cLatLng = addedLatLng;
+		}
+
+		// when showing clusters, take weighted average of all points as cluster center
 		var totalCount = this._childCount + addedCount;
 
-		if (!this._latlng) {
-			this._latlng = new L.LatLng(addedLatLng.lat, addedLatLng.lng);
+		//Calculate weighted latlng for display
+		if (!this._wLatLng) {
+			this._wLatLng = new L.LatLng(addedLatLng.lat, addedLatLng.lng);
 		} else {
-			this._latlng.lat = (addedLatLng.lat * addedCount + this._latlng.lat * this._childCount) / totalCount;
-			this._latlng.lng = (addedLatLng.lng * addedCount + this._latlng.lng * this._childCount) / totalCount;
+			this._wLatLng.lat = (addedLatLng.lat * addedCount + this._wLatLng.lat * this._childCount) / totalCount;
+			this._wLatLng.lng = (addedLatLng.lng * addedCount + this._wLatLng.lng * this._childCount) / totalCount;
 		}
 	},
 
@@ -739,7 +745,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);
@@ -1004,7 +1010,7 @@ L.MarkerCluster = L.Marker.extend({
 		if (this._childCount === 0) {
 			delete this._latlng;
 		} else {
-			this.setLatLng(this._bounds.getCenter());
+			this.setLatLng(this._wLatLng);
 		}
 	},
 
diff --git a/dist/leaflet.markercluster.js b/dist/leaflet.markercluster.js
index d593fca..079f09f 100644
--- a/dist/leaflet.markercluster.js
+++ b/dist/leaflet.markercluster.js
@@ -3,4 +3,4 @@
  Leaflet.markercluster is an open-source JavaScript library for Marker Clustering on leaflet powered maps.
  https://github.com/danzel/Leaflet.markercluster
 */
-(function(e,t){L.MarkerClusterGroup=L.FeatureGroup.extend({options:{maxClusterRadius:60,iconCreateFunction:null,spiderfyOnMaxZoom:!0,showCoverageOnHover:!0,zoomToBoundsOnClick:!0},initialize:function(e){L.Util.setOptions(this,e),this.options.iconCreateFunction||(this.options.iconCreateFunction=this._defaultIconCreateFunction),L.FeatureGroup.prototype.initialize.call(this,[]),this._inZoomAnimation=0,this._needsClustering=[],this._currentShownBounds=null},addLayer:function(e){if(!this._map [...]
\ No newline at end of file
+(function(e,t){L.MarkerClusterGroup=L.FeatureGroup.extend({options:{maxClusterRadius:80,iconCreateFunction:null,spiderfyOnMaxZoom:!0,showCoverageOnHover:!0,zoomToBoundsOnClick:!0},initialize:function(e){L.Util.setOptions(this,e),this.options.iconCreateFunction||(this.options.iconCreateFunction=this._defaultIconCreateFunction),L.FeatureGroup.prototype.initialize.call(this,[]),this._inZoomAnimation=0,this._needsClustering=[],this._currentShownBounds=null},addLayer:function(e){if(!this._map [...]
\ No newline at end of file

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