Skip to content

Guard against invalid camera values in map events#1023

Merged
usefulthink merged 2 commits into
visgl:mainfrom
tzh476:guard-invalid-camera-events
Jul 20, 2026
Merged

Guard against invalid camera values in map events#1023
usefulthink merged 2 commits into
visgl:mainfrom
tzh476:guard-invalid-camera-events

Conversation

@tzh476

@tzh476 tzh476 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

This prevents invalid camera values returned by the Maps API from being turned into fallback camera state inside the Map component.

In particular, when a bounds_changed event reads an invalid camera snapshot such as a non-finite zoom value, the component now:

  • skips updating the internal tracked camera state instead of overwriting it with fallback values like zoom: 0
  • skips emitting an onCameraChanged event with synthetic fallback bounds/center/zoom
  • keeps the existing warning so unexpected Maps API values remain visible to developers

This is a defensive fix for one feedback-loop failure mode discussed in #563. It does not claim to fix every underlying Maps JS API pinch-zoom issue, but it avoids amplifying invalid camera snapshots through React state and controlled camera updates.

Tests

  • npm test

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 55f9af1fa7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/map/use-tracked-camera-state-ref.ts
@usefulthink

Copy link
Copy Markdown
Collaborator

Thanks so much! I've been wanting to figure out a better solution for a while now..

@usefulthink
usefulthink merged commit b487463 into visgl:main Jul 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants