Anagio
Anagio

Reputation: 3075

Google Maps API Geocode Postal Code and set Country code?

I'm using this API call to Google Maps to get the latitude and longitude of a postal code

http://maps.googleapis.com/maps/api/geocode/json?address=2340&sensor=false

The postal code is in Australia. This API call returns locations all around the world with partial matching postal codes in the address.

Is there a parameter I can use to set the country to Australia?

Thanks

Upvotes: 19

Views: 41029

Answers (2)

Alix Axel
Alix Axel

Reputation: 154701

The correct way to do this is not via region biasing but rather using component filtering:

https://maps.google.com/maps/api/geocode/json
    ?components=country:AU|postal_code:2340
    &sensor=false

Some demonstrations:

Please note that if you use the components parameter, you don't need to specify the address parameter.

Upvotes: 40

geocodezip
geocodezip

Reputation: 161404

The documentation says that Region Biasing is based on CcTLDs, which would make Australia au (haven't tried it myself).

Although it also states this:

Note that biasing only prefers results for a specific domain; if more relevant results exist outside of this domain, they may be included.

Upvotes: 2

Related Questions