Google Maps API Geocode Postal Code and set Country code?

后端 未结 2 729
星月不相逢
星月不相逢 2021-02-05 12:53

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

相关标签:
2条回答
  • 2021-02-05 13:23

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

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

    Some demonstrations:

    • 2340
    • 93274

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

    0 讨论(0)
  • 2021-02-05 13:33

    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.

    0 讨论(0)
提交回复
热议问题