[Pkg-javascript-commits] [leaflet-markercluster] 158/479: Clone the LatLng rather than taking a reference so we don't break it when we edit it.

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:24 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 aed28169864424daaa6a680f0a7173811187efcd
Author: danzel <danzel at localhost.geek.nz>
Date:   Fri Aug 10 16:05:49 2012 +1200

    Clone the LatLng rather than taking a reference so we don't break it when we edit it.
---
 src/MarkerCluster.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js
index cb8a033..eb0d05c 100644
--- a/src/MarkerCluster.js
+++ b/src/MarkerCluster.js
@@ -46,6 +46,7 @@ L.MarkerCluster = L.Marker.extend({
 	},
 
 	_addChild: function (new1) {
+		this._expandBounds(new1);
 		if (new1 instanceof L.MarkerCluster) {
 			this._childClusters.push(new1);
 			this._childCount += new1._childCount;
@@ -58,7 +59,6 @@ L.MarkerCluster = L.Marker.extend({
 			this.setIcon(this._group.options.iconCreateFunction(this._childCount));
 		}
 
-		this._expandBounds(new1);
 	},
 
 	_expandBounds: function (marker) {
@@ -79,7 +79,7 @@ L.MarkerCluster = L.Marker.extend({
 		var totalCount = this._childCount + addedCount;
 
 		if (!this._latlng) {
-			this._latlng = addedLatLng;
+			this._latlng = 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;

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