Skip to content

Commit 20adf25

Browse files
committed
Don't track bearing/pitch for view comparison
1 parent 098ccff commit 20adf25

2 files changed

Lines changed: 9 additions & 23 deletions

File tree

src/plots/map/layout_defaults.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,12 @@ function handleDefaults(containerIn, containerOut, coerce, opts) {
4848
// hold the exact values that were auto-computed last time. Skipped when
4949
// the user has explicitly opted out via `fitbounds: false`.
5050
// - `_fitBounds` contains the lon/lat coords for the geometry bounding box
51-
// - `_fitView` contains the view attributes after the MapLibre auto-fit has been completed
52-
const {
53-
_fitView: { center: fitCenter, zoom: fitZoom, bearing: fitBearing, pitch: fitPitch } = {},
54-
center,
55-
zoom,
56-
bearing,
57-
pitch
58-
} = containerIn;
59-
const isFitView =
60-
bearing === fitBearing &&
61-
center?.lon === fitCenter?.lon &&
62-
center?.lat === fitCenter?.lat &&
63-
pitch === fitPitch &&
64-
zoom === fitZoom;
51+
// and is used to store the values passed in to MapLibre for fitting
52+
// - `_fitView` contains the view attributes after the MapLibre auto-fit
53+
// has been completed and is used to determine if the current view is
54+
// still the auto-fit view
55+
const { _fitView: { center: fitCenter, zoom: fitZoom } = {}, center, zoom } = containerIn;
56+
const isFitView = center?.lon === fitCenter?.lon && center?.lat === fitCenter?.lat && zoom === fitZoom;
6557
if (fitbounds && isFitView) {
6658
const fitBounds = getMapFitBounds(opts.fullData, opts.id);
6759
if (fitBounds) containerOut._fitBounds = fitBounds;

src/plots/map/map.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,9 @@ function saveViewToLayout(self, opts) {
241241
opts._input.center = opts.center = center;
242242
opts._input.zoom = opts.zoom = zoom;
243243
// Use below to determine if the current view is still on the fit view during supplyDefaults.
244-
// Bearing and pitch aren't set by auto-fit, but a user change to either signals
245-
// they've engaged with the view and don't want it refit under them. `_fitView` represents
246-
// the view attributes returned by MapLibre after the auto-fit has been completed.
247-
opts._input._fitView = {
248-
center: { ...center },
249-
zoom,
250-
bearing: opts._input.bearing,
251-
pitch: opts._input.pitch
252-
};
244+
// `_fitView` represents the view attributes returned by MapLibre after the auto-fit has been
245+
// completed.
246+
opts._input._fitView = { center: { ...center }, zoom };
253247
}
254248

255249
// Snapshot the current map view state for the Reset view modebar

0 commit comments

Comments
 (0)