Loading...
Sign in to see the examples with your own API key.

Google Places fallback

LINZ's NZ Addresses data holds addresses but no business names, so someone typing a shop's or a building's name finds nothing. Switch on the free Google Places fallback and, only when no address is found, 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 LINZ data; Google is only asked for establishments.

What a Google pick looks like

A picked Google place fills your form from Google's own address parts. It is not a LINZ address, so it has no LINZ address_id to store and pass to Get later. The picked suggestion's provider is 'google'; check it before keeping an id.

input.addEventListener('getaddress-nz-autocomplete-address-selected', e => {
    if (e.suggestion.provider === 'google') {
        // Not a LINZ address: there is no address_id to keep.
    }
});

Keeping one page on LINZ addresses only

Pass google_places_fallback: false to the JavaScript Autocomplete on that page.

getAddressNz.autocomplete('address', '{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.

Top