fix: handle autofit for configured center properly

This commit is contained in:
ccmdi 2025-11-23 09:10:07 -05:00
parent 3a3940ddd5
commit b839de62d2
No known key found for this signature in database
2 changed files with 6 additions and 6 deletions

View file

@ -378,7 +378,7 @@ export function updateMapPoints(deck: Deck<MapViewType[]>, points: MapPoint[], c
const hasConfiguredCenter = options.center && (options.center[0] !== 0 || options.center[1] !== 0);
if (autoCenter && hasConfiguredCenter && options.zoom) {
if (hasConfiguredCenter && options.zoom) {
if (!options.center) return;
shouldTransition = true;
targetViewState = {

View file

@ -336,11 +336,11 @@ export class MapBasesView extends BasesView {
const configChanged = this.hasConfigMeaningfullyChanged();
this.lastConfigState = { ...this.config.data };
const shouldAutoCenter = this.plugin.settings.autoCenter && (autofit === true || (autofit === undefined && (locationsChanged || configChanged)));
this.lastPoints = points;
const shouldAutoCenter = this.plugin.settings.autoCenter && !hasConfiguredCenter && (autofit === true || (autofit === undefined && (locationsChanged || configChanged)));
const shouldUseConfiguredCenter = hasConfiguredCenter && (autofit !== false); //TODO: slight hack
updateMapPoints(this.deck, points, {
containerEl: this.mapEl,
app: this.app,
@ -348,8 +348,8 @@ export class MapBasesView extends BasesView {
tagSettings: this.plugin.tagSettings,
options: {
markerType: this.getMarkerType(),
center: hasConfiguredCenter ? center : undefined,
zoom: hasConfiguredCenter ? this.getDefaultZoom() : undefined,
center: shouldUseConfiguredCenter ? center : undefined,
zoom: shouldUseConfiguredCenter ? this.getDefaultZoom() : undefined,
autoCenter: shouldAutoCenter
}
});