Skip to content

Commit a8b2ee3

Browse files
committed
fix(map-server): use [localStorage] log prefix, add home button debug log
1 parent 36fd39b commit a8b2ee3

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ function persistViewState(cesiumViewer: any): void {
146146

147147
try {
148148
localStorage.setItem(key, JSON.stringify(state));
149-
log.info("[ViewState] saved to", key, state);
149+
log.info("[localStorage] saved", key, state);
150150
} catch (e) {
151-
log.warn("[ViewState] save failed:", e);
151+
log.warn("[localStorage] save failed:", e);
152152
}
153153
}
154154

@@ -161,7 +161,7 @@ function loadPersistedViewState(): PersistedCameraState | null {
161161
try {
162162
const stored = localStorage.getItem(key);
163163
if (!stored) {
164-
log.info("[ViewState] none found for", key);
164+
log.info("[localStorage] no data for", key);
165165
return null;
166166
}
167167

@@ -172,13 +172,13 @@ function loadPersistedViewState(): PersistedCameraState | null {
172172
typeof state.latitude !== "number" ||
173173
typeof state.height !== "number"
174174
) {
175-
log.warn("[ViewState] invalid data, ignoring:", state);
175+
log.warn("[localStorage] invalid data for", key, state);
176176
return null;
177177
}
178-
log.info("[ViewState] loaded from", key, state);
178+
log.info("[localStorage] loaded", key, state);
179179
return state;
180180
} catch (e) {
181-
log.warn("[ViewState] load failed:", e);
181+
log.warn("[localStorage] load failed:", e);
182182
return null;
183183
}
184184
}
@@ -823,8 +823,12 @@ const DEFAULT_BOUNDING_BOX: BoundingBox = {
823823
*/
824824
function setupHomeButton(cesiumViewer: any): void {
825825
const btn = document.getElementById("home-btn");
826-
if (!btn) return;
826+
if (!btn) {
827+
log.warn("Home button element not found");
828+
return;
829+
}
827830

831+
log.info("Setting up home button");
828832
btn.style.display = "flex";
829833
btn.addEventListener("click", () => {
830834
// Use initial bbox from tool input, or default to USA view
@@ -1024,7 +1028,7 @@ app.ontoolinput = async (params) => {
10241028
// Check if we have a persisted view state - if so, use it instead of tool input
10251029
const persistedState = loadPersistedViewState();
10261030
if (persistedState) {
1027-
log.info("[ViewState] using persisted view instead of tool input");
1031+
log.info("[localStorage] using persisted view instead of tool input");
10281032
restorePersistedView(viewer);
10291033
} else {
10301034
log.info("Positioning camera to tool input bbox:", bbox);

0 commit comments

Comments
 (0)