Skip to content

Commit 36fd39b

Browse files
committed
fix(map-server): localStorage view state takes precedence over tool input
Persisted user panning is now restored instead of using tool input bbox. Tool input bbox is still stored for the home button.
1 parent ad95e31 commit 36fd39b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

examples/map-server/src/mcp-app.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,18 +1014,22 @@ app.ontoolinput = async (params) => {
10141014
}
10151015

10161016
if (bbox) {
1017-
// Mark that we received explicit tool input (overrides persisted state)
10181017
hasReceivedToolInput = true;
10191018

1020-
// Store initial bbox for home button (first tool input becomes the "home" view)
1019+
// Store tool input bbox for home button (first tool input becomes the "home" view)
10211020
if (!initialBoundingBox) {
10221021
initialBoundingBox = bbox;
10231022
}
10241023

1025-
log.info("Positioning camera to bbox:", bbox);
1026-
1027-
// Position camera instantly (no animation)
1028-
setViewToBoundingBox(viewer, bbox);
1024+
// Check if we have a persisted view state - if so, use it instead of tool input
1025+
const persistedState = loadPersistedViewState();
1026+
if (persistedState) {
1027+
log.info("[ViewState] using persisted view instead of tool input");
1028+
restorePersistedView(viewer);
1029+
} else {
1030+
log.info("Positioning camera to tool input bbox:", bbox);
1031+
setViewToBoundingBox(viewer, bbox);
1032+
}
10291033

10301034
// Wait for tiles to load at this location
10311035
await waitForTilesLoaded(viewer);

0 commit comments

Comments
 (0)