Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt to fix issue #46 #47

Merged
merged 8 commits into from
Jul 26, 2017
22 changes: 16 additions & 6 deletions L.Map.Sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@
this.getZoom(), NO_ANIMATION);
}
if (options.syncCursor) {
map.cursor = L.circleMarker([0, 0], options.syncCursorMarkerOptions).addTo(map);
if (typeof map.cursor === 'undefined') {
map.cursor = L.circleMarker([0, 0], options.syncCursorMarkerOptions).addTo(map);
}

this._cursors.push(map.cursor);

Expand All @@ -83,19 +85,27 @@
unsync: function (map) {
var self = this;

if (this._cursors) {
this._cursors.forEach(function (cursor, indx, _cursors) {
if (cursor === map.cursor) {
_cursors.splice(indx, 1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a semicolon here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jieter you are right... but eslint has not detected it (tests are ok). Shouldn't be eslint configuration more strict? (sure, this is for another PR, not now)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I agree. I also noticed some other oddities in unchanged lines, we should have a look at that. I can fix this line then too, so merging ;)

}
});
}

// TODO: hide cursor in stead of moving to 0, 0
if (map.cursor) {
map.cursor.setLatLng([0, 0]);
}

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.
Expand Down