[Pkg-javascript-commits] [leaflet-markercluster] 03/128: Rough marker move tracking. refs #57

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 27827b5d63317aa7fb6800500984857ca24f16fa
Author: danzel <danzel at localhost.geek.nz>
Date:   Wed Jan 29 16:43:51 2014 +1300

    Rough marker move tracking. refs #57
---
 src/MarkerClusterGroup.js | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index ed21d4d..08696dd 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -146,6 +146,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		//Remove the marker from clusters
 		this._removeLayer(layer, true);
 
+		layer.off('move', this._childMarkerMoved, this);
+
 		if (this._featureGroup.hasLayer(layer)) {
 			this._featureGroup.removeLayer(layer);
 			if (layer.setOpacity) {
@@ -309,6 +311,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		this._nonPointGroup.clearLayers();
 
 		this.eachLayer(function (marker) {
+			marker.off('move', this._childMarkerMoved, this);
 			delete marker.__parent;
 		});
 
@@ -519,6 +522,40 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		}
 	},
 
+	_childMarkerMoved: function (e) {
+
+		e.target._latlng = e.oldLatLng;
+		this.removeLayer(e.target);
+
+		e.target._latlng = e.latlng;
+		this.addLayer(e.target);
+
+		return;
+		this._removeLayer(e.layer, true);
+
+		//?????
+		if (this._featureGroup.hasLayer(layer)) {
+			this._featureGroup.removeLayer(layer);
+			if (layer.setOpacity) {
+				layer.setOpacity(1);
+			}
+		}
+
+		e.layer._latlng = e.latlng;
+		this._addLayer(e.layer);
+
+		//Work out what is visible
+		var visibleLayer = this.getVisibleParent(e.layer);
+
+		if (this._currentShownBounds.contains(visibleLayer.getLatLng())) {
+			if (this.options.animateAddingMarkers) {
+				this._animationAddLayer(layer, visibleLayer);
+			} else {
+				this._animationAddLayerNonAnimated(layer, visibleLayer);
+			}
+		}
+	},
+
 	//Internal function for removing a marker from everything.
 	//dontUpdateMap: set to true if you will handle updating the map manually (for bulk functions)
 	_removeLayer: function (marker, removeFromDistanceGrid, dontUpdateMap) {
@@ -768,6 +805,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 			});
 		}
 
+		layer.on('move', this._childMarkerMoved, this);
+
 		//Find the lowest zoom level to slot this one in
 		for (; zoom >= 0; zoom--) {
 			markerPoint = this._map.project(layer.getLatLng(), zoom); // calculate pixel position

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