From 4a12d6696a6c02c8b7442110f538452aa3c32032 Mon Sep 17 00:00:00 2001 From: solsTiCe d'Hiver Date: Sat, 15 Jul 2017 20:45:36 +0200 Subject: [PATCH 1/7] Don't re-create map.cursor if it's already created * This will able us to correctly track its use --- L.Map.Sync.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/L.Map.Sync.js b/L.Map.Sync.js index 9651761..3132175 100644 --- a/L.Map.Sync.js +++ b/L.Map.Sync.js @@ -61,7 +61,9 @@ this.getZoom(), NO_ANIMATION); } if (options.syncCursor) { - map.cursor = L.circleMarker([0, 0], options.syncCursorMarkerOptions).addTo(map); + if (map.cursor === undefined) { + map.cursor = L.circleMarker([0, 0], options.syncCursorMarkerOptions).addTo(map); + } this._cursors.push(map.cursor); From 4bb3725af5adc2bf2273b71ed93aee9c3184be4a Mon Sep 17 00:00:00 2001 From: solsTiCe d'Hiver Date: Sat, 15 Jul 2017 20:51:29 +0200 Subject: [PATCH 2/7] Fix syncCursor issue with more than 2 maps * When unsyncing 2 maps in a set of 3, cursor disappear on map not unsynced. * This fixes this by removing the cursor from the list of _cursors to follow (using the previous commit) and not remove the cursor on the synced map (because it might used by another map) and its callback --- L.Map.Sync.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/L.Map.Sync.js b/L.Map.Sync.js index 3132175..92ad306 100644 --- a/L.Map.Sync.js +++ b/L.Map.Sync.js @@ -100,23 +100,27 @@ unsync: function (map) { var self = this; + this._cursors.forEach(function(cursor, indx, _cursors) { + if (cursor === map.cursor) { + _cursors.splice(indx, 1) + } + }); + if (this._syncMaps) { this._syncMaps.forEach(function (synced, id) { if (map === synced) { delete self._syncOffsetFns[L.Util.stamp(map)]; self._syncMaps.splice(id, 1); - if (map.cursor) { - map.cursor.removeFrom(map); - } } }); } - this.off('mousemove', this._cursorSyncMove, this); - this.off('mouseout', this._cursorSyncOut, this); if (!this._syncMaps || this._syncMaps.length == 0) { // no more synced maps, so these events are not needed. this.off('resize zoomend dragstart click', this._selfSetView); + + this.off('mousemove', this._cursorSyncMove, this); + this.off('mouseout', this._cursorSyncOut, this); } return this; From 3f35c1a88c6c0ad42566af5ee3f1a5c26d23b64f Mon Sep 17 00:00:00 2001 From: solsTiCe d'Hiver Date: Sat, 15 Jul 2017 23:02:16 +0200 Subject: [PATCH 3/7] Fix travis warning about style issue --- L.Map.Sync.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L.Map.Sync.js b/L.Map.Sync.js index 92ad306..efabeff 100644 --- a/L.Map.Sync.js +++ b/L.Map.Sync.js @@ -100,7 +100,7 @@ unsync: function (map) { var self = this; - this._cursors.forEach(function(cursor, indx, _cursors) { + this._cursors.forEach(function (cursor, indx, _cursors) { if (cursor === map.cursor) { _cursors.splice(indx, 1) } From a4d81d30b368ebb838db772f4bace300d024df28 Mon Sep 17 00:00:00 2001 From: solsTiCe d'Hiver Date: Sat, 15 Jul 2017 23:02:44 +0200 Subject: [PATCH 4/7] Hide cursor when unsyncing * This mimicks the previous behavior --- L.Map.Sync.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/L.Map.Sync.js b/L.Map.Sync.js index efabeff..e9917d3 100644 --- a/L.Map.Sync.js +++ b/L.Map.Sync.js @@ -106,6 +106,9 @@ } }); + // TODO: hide cursor in stead of moving to 0, 0 + map.cursor.setLatLng([0, 0]); + if (this._syncMaps) { this._syncMaps.forEach(function (synced, id) { if (map === synced) { From 23160884304609c9e88420383918302dbc58c69f Mon Sep 17 00:00:00 2001 From: solsTiCe d'Hiver Date: Sat, 15 Jul 2017 23:10:14 +0200 Subject: [PATCH 5/7] Fix travis warning about undefined --- L.Map.Sync.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L.Map.Sync.js b/L.Map.Sync.js index e9917d3..bb8f433 100644 --- a/L.Map.Sync.js +++ b/L.Map.Sync.js @@ -61,7 +61,7 @@ this.getZoom(), NO_ANIMATION); } if (options.syncCursor) { - if (map.cursor === undefined) { + if (typeof map.cursor === "undefined") { map.cursor = L.circleMarker([0, 0], options.syncCursorMarkerOptions).addTo(map); } From 32d08c09e785b23e78faec70bb1318443a825777 Mon Sep 17 00:00:00 2001 From: solsTiCe d'Hiver Date: Sat, 15 Jul 2017 23:12:57 +0200 Subject: [PATCH 6/7] Fix double quote issue with travis --- L.Map.Sync.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L.Map.Sync.js b/L.Map.Sync.js index bb8f433..716acf4 100644 --- a/L.Map.Sync.js +++ b/L.Map.Sync.js @@ -61,7 +61,7 @@ this.getZoom(), NO_ANIMATION); } if (options.syncCursor) { - if (typeof map.cursor === "undefined") { + if (typeof map.cursor === 'undefined') { map.cursor = L.circleMarker([0, 0], options.syncCursorMarkerOptions).addTo(map); } From 91d2a93f460398e35e491bef71eb55a332530db0 Mon Sep 17 00:00:00 2001 From: solsTiCe d'Hiver Date: Sat, 15 Jul 2017 23:23:04 +0200 Subject: [PATCH 7/7] Attempt to fix travis warning again --- L.Map.Sync.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/L.Map.Sync.js b/L.Map.Sync.js index 716acf4..304b2f9 100644 --- a/L.Map.Sync.js +++ b/L.Map.Sync.js @@ -100,14 +100,18 @@ unsync: function (map) { var self = this; - this._cursors.forEach(function (cursor, indx, _cursors) { - if (cursor === map.cursor) { - _cursors.splice(indx, 1) - } - }); + if (this._cursors) { + this._cursors.forEach(function (cursor, indx, _cursors) { + if (cursor === map.cursor) { + _cursors.splice(indx, 1) + } + }); + } // TODO: hide cursor in stead of moving to 0, 0 - map.cursor.setLatLng([0, 0]); + if (map.cursor) { + map.cursor.setLatLng([0, 0]); + } if (this._syncMaps) { this._syncMaps.forEach(function (synced, id) {