From cfb795849a58ec979f2bbba79e56e6293b9c3c2f Mon Sep 17 00:00:00 2001 From: hubertkozik Date: Tue, 14 Mar 2023 13:18:04 +0100 Subject: [PATCH] Fixed #18542, panning in zoomed-in Orthographic projection didn't work. --- samples/unit-tests/maps/map-navigation/demo.js | 7 +++++++ ts/Maps/MapView.ts | 11 ++++++++++- ts/Series/Map/MapSeries.ts | 6 +++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/samples/unit-tests/maps/map-navigation/demo.js b/samples/unit-tests/maps/map-navigation/demo.js index df7891d4cff..893d60e317e 100644 --- a/samples/unit-tests/maps/map-navigation/demo.js +++ b/samples/unit-tests/maps/map-navigation/demo.js @@ -342,6 +342,8 @@ QUnit.test('Orthographic map rotation and panning.', assert => { // Zoom needed to pan initially. chart.mapView.zoomBy(1); + const beforeZoom = chart.mapView.zoom; + controller.pan([305, 50], [350, 150]); // eslint-disable-next-line @@ -395,4 +397,9 @@ QUnit.test('Orthographic map rotation and panning.', assert => { 'Point graphics on the near side should not be hidden' ); + assert.strictEqual( + beforeZoom, + chart.mapView.zoom, + 'Map shouldn\' be zoomed out after panning (#18542).' + ); }); diff --git a/ts/Maps/MapView.ts b/ts/Maps/MapView.ts index 44cf5f28dde..cc0ae2d689f 100644 --- a/ts/Maps/MapView.ts +++ b/ts/Maps/MapView.ts @@ -964,6 +964,7 @@ class MapView { rotation: [-lon, -lat] } }, false); + this.fitToBounds(void 0, void 0, false); this.zoom = zoom; chart.redraw(false); @@ -1110,7 +1111,15 @@ class MapView { } // Fit to natural bounds if center/zoom are not explicitly given - if (!options.center && !isNumber(options.zoom)) { + if ( + !options.center && + // do not fire fitToBounds if user don't want to set zoom + Object.hasOwnProperty.call( + options, + 'zoom' + ) && + !isNumber(options.zoom) + ) { this.fitToBounds(void 0, void 0, false); } } diff --git a/ts/Series/Map/MapSeries.ts b/ts/Series/Map/MapSeries.ts index c2487726d25..f68aaf231e1 100644 --- a/ts/Series/Map/MapSeries.ts +++ b/ts/Series/Map/MapSeries.ts @@ -1239,7 +1239,11 @@ class MapSeries extends ScatterSeries { if ( mapView && !mapView.userOptions.center && - !isNumber(mapView.userOptions.zoom) + !isNumber(mapView.userOptions.zoom) && + Object.hasOwnProperty.call( + this.userOptions, + 'allAreas' + ) ) { // Not only recalculate bounds but also fit view mapView.fitToBounds(void 0, void 0, false); // #17012