nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit 8cbb4dbd8cb7dc0cebc8b4e28bcc2cf3059d8590
parent 651949de6bd840a20cc3c5c846c7ade78d7f3670
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Wed,  7 Nov 2018 09:53:40 +0100

Merge branch '155-track-zoom-180' into release-5

Diffstat:
Msrc/lib/leaflet.control.track-list/track-list.js | 2+-
Msrc/lib/leaflet.fixes/fixWorldCopyJump.js | 19++++++++++++-------
2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/lib/leaflet.control.track-list/track-list.js b/src/lib/leaflet.control.track-list/track-list.js @@ -378,7 +378,7 @@ L.Control.TrackList = L.Control.extend({ } ); if (bounds.isValid()) { - bounds = wrapLatLngBoundsToTarget(bounds, this.map.getBounds()); + bounds = wrapLatLngBoundsToTarget(bounds, this.map.getCenter()); if (L.Browser.mobile) { this.map.fitBounds(bounds); } else { diff --git a/src/lib/leaflet.fixes/fixWorldCopyJump.js b/src/lib/leaflet.fixes/fixWorldCopyJump.js @@ -1,6 +1,14 @@ import L from 'leaflet'; function shiftLongitudeToTarget(lng, targetLng) { + if (targetLng instanceof L.LatLngBounds) { + if (!targetLng.isValid()) { + return 0; + } + targetLng = targetLng.getCenter().lng; + } else if (targetLng instanceof L.LatLng) { + targetLng = targetLng.lng; + } let shift = 0; if (Math.abs(lng + 360 - targetLng) < Math.abs(lng - targetLng)) { shift = 360; @@ -10,16 +18,13 @@ function shiftLongitudeToTarget(lng, targetLng) { return shift; } -function wrapLatLngToTarget(latLng, targetLatLng) { - const shift = shiftLongitudeToTarget(latLng.lng, targetLatLng.lng); +function wrapLatLngToTarget(latLng, targetLng) { + const shift = shiftLongitudeToTarget(latLng.lng, targetLng); return L.latLng(latLng.lat, latLng.lng + shift); } -function wrapLatLngBoundsToTarget(latLngBounds, targetLatLngBounds) { - if (!targetLatLngBounds.isValid()) { - return latLngBounds; - } - const shift = shiftLongitudeToTarget(latLngBounds.getCenter().lng, targetLatLngBounds.getCenter().lng); +function wrapLatLngBoundsToTarget(latLngBounds, targetLng) { + const shift = shiftLongitudeToTarget(latLngBounds.getCenter().lng, targetLng); const p1 = latLngBounds.getSouthEast(); const p2 = latLngBounds.getNorthWest(); return L.latLngBounds([[p1.lat, p1.lng + shift], [p2.lat, p2.lng + shift]]);