Skip to content

fix(demo): implement Place Autocomplete for Region Search#41

Merged
anubis05 merged 1 commit intomainfrom
feat/demo-autocomplete-region-search
Mar 11, 2026
Merged

fix(demo): implement Place Autocomplete for Region Search#41
anubis05 merged 1 commit intomainfrom
feat/demo-autocomplete-region-search

Conversation

@henrikvalv3
Copy link
Copy Markdown
Collaborator

Background & Motivation
Previously, the Region Search feature relied on users free-typing a region name and manually selecting an administrative level (e.g., "Manhattan" + "Locality"). This resulted in naming collisions (e.g., querying Manhattan, KS instead of Manhattan, NY).

Changes Made

  • UI Update: Replaced the free-text input and dropdown with the Google Maps PlaceAutocompleteElement component, restricted to the user's active country.
  • Exact ID Querying: The application now extracts the exact Place ID and types array from the selected prediction, maps the type to the correct BigQuery column, and passes the ID into the SQL query.
  • Schema Handling: Updated state.js and query.js to correctly distinguish between BigQuery STRING fields (e.g., administrative_area_level_1_id for states/countries) and ARRAY fields (e.g., locality_ids for cities), generating the appropriate = or UNNEST() SQL syntax to prevent column-not-found errors.
  • Dynamic Map Framing: Leveraged the viewport property from the Places API to perfectly fit the map bounds to the selected region's true geometry, preventing the map from over-zooming on a single center coordinate.
  • Minor UX Fix: Ensure that if a user types a brand name into the brand filter input but forgets to click the "+" add button, the pending input is still appended and included in the query.

Impact
This guarantees accuracy when searching for administrative areas, removes the cognitive load on the user to guess the correct region type, and provides a much smoother map zooming experience.

@henrikvalv3 henrikvalv3 requested a review from anubis05 March 11, 2026 15:50
@anubis05 anubis05 merged commit 01ae9d5 into main Mar 11, 2026
4 checks passed
@henrikvalv3 henrikvalv3 deleted the feat/demo-autocomplete-region-search branch March 11, 2026 15:56
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