Google Places fallback
G-NAF has every address in Australia but no business names, so someone typing Westfield Bondi Junction finds nothing. Switch on the free Google Places fallback and, only when G-NAF finds nothing, the JavaScript Autocomplete searches Google for businesses and places with your own Google API key, straight from the visitor's browser. Addresses always come from G-NAF; Google is only asked for establishments.
- Switch it on, and paste your key, on the Add-ons tab of your console. It applies to every domain token on that subscription, and reaches your pages within a few minutes. Nothing changes in your page code.
- It only runs with a domain token. An API key used from a server never gets a fallback.
- Google bills your Google Cloud account. We don't charge for it, and a Google result never counts as a look-up.
- Restrict the key in Google Cloud: allow only your websites, and only the Maps JavaScript API and Places API (New). The key is sent to visitors' browsers.
- Google results are listed with the text Google Maps beneath them, as Google's terms require. Keep it visible if you restyle the list.
- The widget loads the Maps JavaScript API from
maps.googleapis.comthe first time it is needed. If your site has a Content Security Policy, allowmaps.googleapis.comandmaps.gstatic.com; if it can't load, the fallback reports an error and the field carries on as before.
What a Google pick looks like
A picked Google place fills your form the same way a G-NAF address does. The record has the same fields, with
cleaning_provenance set to {"Source": "GOOGLE"}, the place's name in address_site_name, and
everything only G-NAF knows — address_detail_pid, mb_code, legal_parcel_id,
geocode_type, level and lot — empty. Check cleaning_provenance before storing an id to pass to
Get later.
input.addEventListener('getaddress-au-autocomplete-address-selected', e => {
if (e.address.cleaning_provenance.Source === 'GOOGLE') {
// Not in G-NAF: there is no address_detail_pid to keep.
}
});
Keeping one page on G-NAF only
Pass google_places_fallback: false to the JavaScript Autocomplete on that page.
getAddressAu.autocomplete('address_line_1', '{your-domain-token}', { google_places_fallback: false });
In the API
The Autocomplete response carries your key as fallback when a domain-token request finds no suggestions.