Google Maps API defaults to NYC

Hi Guys - I thought I had fixed this but struggling for few hours, chatgpt ain’t helping me!

Setup google maps API keys all good, but without any listings (airBnB template) default is always NYC!!!

Can you please advise on how to set default location to Melbourne Australia please - thank you in advance!!!

@roger11 are you usign any plugin or a script ?

This usually isn’t a Google Maps API problem. New York appears because when Bubble doesn’t receive an initial location, Google Maps defaults to NYC automatically. To fix this, you need to explicitly set a default location. The easiest way is to select your Map element and set the initial latitude to -37.8136 and longitude to 144.9631, which will center the map on Melbourne, Australia. If you are using an Airbnb-style setup with a repeating group, also make sure your data source has a location constraint, for example searching for listings within a certain distance of Melbourne. If you are using a custom state for location, ensure it is set on page load, because an empty custom state will cause the map to fall back to New York. A common mistake is relying on the map to auto-detect a location or loading the map before a workflow sets the location. In production apps, it’s best practice to always set both the map’s initial latitude/longitude and a default location for your search so the map never falls back to NYC.

thank you so much, could you please explain which field I use to set latitude and longitude, sorry can’t remember!

Looks like achieved through a workflow, but struggling to write correct logic!

Tried Custom State but still not updating ?

Showing in editor as Melbourne but not showing in test page?

This isn’t actually a Google Maps API issue. What’s happening is that when a Bubble map loads without a valid center location at runtime, Google Maps automatically falls back to New York City. That’s why you’re seeing Melbourne in the editor (because the editor reads default values), but NYC in preview or test mode (because the map initializes before it receives a real location).

From your screenshots, the main problem is that the map is still receiving an empty or invalid location when the page loads. Your custom state is defined as a list of geographic addresses, and when that list is empty (which it is on first load), Bubble sends “nothing” to the map. When that happens, Google defaults to NYC.

The correct and reliable fix is to explicitly force the map’s center on page load, instead of relying on “Make changes to element” or editor defaults.

First, update your custom state. The custom state used for the default location should be a single geographic address, not a list. For example, keep a custom state like australia_location with type Geographic address (not a list) and set its default value to Melbourne VIC, Australia. A map center can only be one location, so using a list causes Bubble to fail silently at runtime.

Next, create a workflow on Page is loaded. In this workflow, set the custom state australia_location to Melbourne VIC, Australia (you can type this directly as a geographic address). Immediately after that, add the map action “Set map to location” (or equivalent for your map element/plugin) and pass Map A’s australia_location as the location, with a reasonable zoom level (for example 11–13). This step is critical. Changing latitude/longitude via “Make changes to element” does not reliably re-center the map in preview, but the map’s own “Set map to location” action does.

If your Airbnb-style setup normally centers the map based on listings, you also need to handle the empty state explicitly. When there are listings, the map can be centered on the first listing’s location. But when the list is empty, you must force the map back to Melbourne. The safest way is to add logic so that when the search or repeating group count is 0, the map is set to Melbourne, and when the count is greater than 0, the map is set to the first property’s location. Without this fallback, the moment the data source is empty, the map reverts to NYC.

Regarding latitude and longitude specifically: Bubble maps work best with Geographic address fields. You do not need to manually enter -37.8136 and 144.9631 unless you have a very specific reason. Using “Melbourne VIC, Australia” as a geographic address is cleaner and more stable. If you do rely on coordinates, they still must resolve into a valid geographic address before being sent to the map.

So in short, Melbourne shows in the editor because the editor reads defaults, but NYC shows in preview because the map initializes before it receives a valid center. Converting the custom state to a single geographic address and forcing “Set map to location” on page load (and when listings are empty) ensures the map never falls back to New York again.

thank you so much for taking the time to explain so well, appreciate this will update this weekend and test. I owe you a beer if you visit Melbourne, which is a good idea for this forum to allow ‘buy me a coffee’ payments - thanks again

thanks.