Skip to main content

Why does my app return the wrong city or address for some international locations?

Google's autocomplete API returns a place's address based on its display name rather than precise pin coordinates, which can result in a neighbourhood or district being returned instead of the city for some international locations.

Written by Sofia Maconi

Bubble uses Google Maps' autocomplete API to search for geographic locations. The API saves a place's address based on its displayed name rather than the precise pin coordinates — and for some non-US locations, this means a neighbourhood or district name is returned instead of the city.

What you might notice

  • Searching for a location returns an address that's less precise than expected — for example, a neighbourhood name instead of the city

  • This happens more frequently for locations outside the United States

Workaround

Add a hidden Map element to your page and set its value to the SearchBox input. The Map element uses the full coordinate data from Google Maps to place a pin, and its "center" property provides more accurate location data than the autocomplete address alone. You can read more in the documentation.

This is a limitation of how Google's autocomplete API returns address data for some locations.

Did this answer your question?