Skip to content

Commit

Permalink
Fixed #18542, panning in zoomed-in Orthographic projection didn't work.
Browse files Browse the repository at this point in the history
  • Loading branch information
hubertkozik authored and TorsteinHonsi committed Mar 29, 2023
1 parent dc32875 commit cfb7958
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
7 changes: 7 additions & 0 deletions samples/unit-tests/maps/map-navigation/demo.js
Expand Up @@ -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
Expand Down Expand Up @@ -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).'
);
});
11 changes: 10 additions & 1 deletion ts/Maps/MapView.ts
Expand Up @@ -964,6 +964,7 @@ class MapView {
rotation: [-lon, -lat]
}
}, false);
this.fitToBounds(void 0, void 0, false);
this.zoom = zoom;
chart.redraw(false);

Expand Down Expand Up @@ -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);
}
}
Expand Down
6 changes: 5 additions & 1 deletion ts/Series/Map/MapSeries.ts
Expand Up @@ -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
Expand Down

0 comments on commit cfb7958

Please sign in to comment.