[Pkg-javascript-commits] [leaflet-markercluster] 02/128: Cludge around setLatLng so we don't cause 'move' events when we hack-move markers. This wants doing better.

Jonas Smedegaard dr at jones.dk
Sun Apr 16 06:25:58 UTC 2017


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

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

commit 51014578d75099191f4a9c9014cf07b4476debea
Author: danzel <danzel at localhost.geek.nz>
Date:   Wed Jan 29 15:12:51 2014 +1300

    Cludge around setLatLng so we don't cause 'move' events when we hack-move markers. This wants doing better.
---
 src/MarkerCluster.js      | 20 ++++++++++++++++----
 src/MarkerClusterGroup.js |  5 ++++-
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js
index a3a7d67..12559ab 100644
--- a/src/MarkerCluster.js
+++ b/src/MarkerCluster.js
@@ -153,7 +153,10 @@ L.MarkerCluster = L.Marker.extend({
 	_addToMap: function (startPos) {
 		if (startPos) {
 			this._backupLatlng = this._latlng;
-			this.setLatLng(startPos);
+
+			//We don't use setLatLng so we don't cause a 'move' event
+			this._latlng = startPos;
+			this.update();
 		}
 		this._group._featureGroup.addLayer(this);
 	},
@@ -230,7 +233,10 @@ L.MarkerCluster = L.Marker.extend({
 					if (startPos) {
 						nm._backupLatlng = nm.getLatLng();
 
-						nm.setLatLng(startPos);
+						//We don't use setLatLng so we don't cause a 'move' event
+						nm._latlng = startPos;
+						nm.update();
+
 						if (nm.setOpacity) {
 							nm.setOpacity(0);
 						}
@@ -250,7 +256,10 @@ L.MarkerCluster = L.Marker.extend({
 		for (var i = this._markers.length - 1; i >= 0; i--) {
 			var nm = this._markers[i];
 			if (nm._backupLatlng) {
-				nm.setLatLng(nm._backupLatlng);
+				//We don't use setLatLng so we don't cause a 'move' event
+				nm._latlng = nm._backupLatlng;
+				nm.update();
+
 				delete nm._backupLatlng;
 			}
 		}
@@ -269,7 +278,10 @@ L.MarkerCluster = L.Marker.extend({
 
 	_restorePosition: function () {
 		if (this._backupLatlng) {
-			this.setLatLng(this._backupLatlng);
+			//We don't use setLatLng so we don't cause a 'move' event
+			this._latlng = this._backupLatlng;
+			this.update();
+
 			delete this._backupLatlng;
 		}
 	},
diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index e261291..ed21d4d 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -1023,7 +1023,10 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
 			if (cluster._childCount === 1) {
 				var m = cluster._markers[0];
 				//If we were in a cluster animation at the time then the opacity and position of our child could be wrong now, so fix it
-				m.setLatLng(m.getLatLng());
+				//We don't use setLatLng so we don't cause a 'move' event
+				m._latlng = m.getLatLng();
+				m.update();
+
 				if (m.setOpacity) {
 					m.setOpacity(1);
 				}

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