[Pkg-javascript-commits] [leaflet-markercluster] 136/479: Revert back to updating the latlng of a marker while it is spiderfied so that popups created on markers that are spidferfied are in the right place.

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:21 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 1be9202f05bbc7c4fce1b9d2fbd9dd6199a7da15
Author: danzel <danzel at localhost.geek.nz>
Date:   Wed Aug 1 15:17:09 2012 +1200

    Revert back to updating the latlng of a marker while it is spiderfied so that popups created on markers that are spidferfied are in the right place.
---
 src/MarkerCluster.Spiderfier.js | 39 +++++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/src/MarkerCluster.Spiderfier.js b/src/MarkerCluster.Spiderfier.js
index c9776a6..c814bce 100644
--- a/src/MarkerCluster.Spiderfier.js
+++ b/src/MarkerCluster.Spiderfier.js
@@ -88,17 +88,20 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
 	_animationSpiderfy: function (childMarkers, positions) {
 		var group = this._group,
 			map = group._map,
-			i, m, leg;
+			i, m, leg, newPos;
 
 		for (i = childMarkers.length - 1; i >= 0; i--) {
+			newPos = map.layerPointToLatLng(positions[i]);
 			m = childMarkers[i];
 
+			m._preSpiderfyLatlng = m._latlng;
+			m.setLatLng(newPos);
 			m.setZIndexOffset(1000000); //Make these appear on top of EVERYTHING
+
 			L.FeatureGroup.prototype.addLayer.call(group, m);
-			m._setPos(positions[i]);
 
 
-			leg = new L.Polyline([this._latlng, map.layerPointToLatLng(positions[i])], { weight: 1.5, color: '#222' });
+			leg = new L.Polyline([this._latlng, newPos], { weight: 1.5, color: '#222' });
 			map.addLayer(leg);
 			m._spiderLeg = leg;
 		}
@@ -115,11 +118,12 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
 		for (i = childMarkers.length - 1; i >= 0; i--) {
 			m = childMarkers[i];
 
-			delete m._backupPosSpider;
-			m.setZIndexOffset(0);
-
 			L.FeatureGroup.prototype.removeLayer.call(group, m);
 
+			m.setLatLng(m._preSpiderfyLatlng);
+			delete m._preSpiderfyLatlng;
+			m.setZIndexOffset(0);
+
 			map.removeLayer(m._spiderLeg);
 			delete m._spiderLeg;
 		}
@@ -131,8 +135,9 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
 			group = this._group,
 			map = group._map,
 			thisLayerPos = map.latLngToLayerPoint(this._latlng),
-			i, m, leg;
+			i, m, leg, newPos;
 
+		//Add markers to map hidden at our center point
 		for (i = childMarkers.length - 1; i >= 0; i--) {
 			m = childMarkers[i];
 
@@ -144,7 +149,7 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
 			m._setPos(thisLayerPos);
 		}
 
-		this._group._forceLayout();
+		group._forceLayout();
 		group._animationStart();
 
 		var initialLegOpacity = L.Browser.svg ? 0 : 0.3,
@@ -152,14 +157,17 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
 
 
 		for (i = childMarkers.length - 1; i >= 0; i--) {
+			newPos = map.layerPointToLatLng(positions[i]);
 			m = childMarkers[i];
 
-			m._setPos(positions[i]);
-
+			//Move marker to new position
+			m._preSpiderfyLatlng = m._latlng;
+			m.setLatLng(newPos);
 			m.setOpacity(1);
-			//Add Legs. TODO: Fade this in!
 
-			leg = new L.Polyline([me._latlng, map.layerPointToLatLng(positions[i])], { weight: 1.5, color: '#222', opacity: initialLegOpacity });
+
+			//Add Legs.
+			leg = new L.Polyline([me._latlng, newPos], { weight: 1.5, color: '#222', opacity: initialLegOpacity });
 			map.addLayer(leg);
 			m._spiderLeg = leg;
 
@@ -232,6 +240,10 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
 		for (i = childMarkers.length - 1; i >= 0; i--) {
 			m = childMarkers[i];
 
+			//Fix up the location to the real one
+			m.setLatLng(m._preSpiderfyLatlng);
+			delete m._preSpiderfyLatlng;
+			//Hack override the location to be our center
 			m._setPos(thisLayerPos);
 
 			m.setOpacity(0);
@@ -316,8 +328,11 @@ L.MarkerClusterGroup.include({
 	_unspiderfyLayer: function (layer) {
 		if (layer._spiderLeg) {
 			L.FeatureGroup.prototype.removeLayer.call(this, layer);
+
 			layer.setOpacity(1);
+			//Position will be fixed up immediately in _animationUnspiderfy
 			layer.setZIndexOffset(0);
+
 			this._map.removeLayer(layer._spiderLeg);
 			delete layer._spiderLeg;
 		}

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