1

I'm utilising google autocomplete to allow visitors to enter towns, suburbs or postcodes, so that they can select the right one from the autocomplete list. I then need to store the postcode for that location so that I can compare that postcode to entries in a database to find service providers in that postcode.

The problem I'm now having is that the Google API doesn't return postcodes for all locations. This especially seems to be the case for larger cities. For example, it doesn't return postcodes for Melbourne Australia, Sydney Australia or Perth Australia.

Has anyone developed a solution or workaround to this issue? Any suggestions?

I've been googling for ages now and can't find a solution. Google itself doesn't seem to mention this situation in their Google Places docs.

CraigD
  • 119
  • 1
  • 10
  • Which of [these dozens of postcodes for Melbourne would you expect to be returned](https://voommaps.com/postcode-maps/map-of-melbourne-postcodes/)? – ceejayoz Jul 02 '19 at 03:25
  • 3000, of course. That's the postcode for physical addresses within the city of Melbourne. Just as 2000 is the postcode for physical addresses within the city of Sydney. All of those others on that link you gave are suburbs, which Google correctly returns in their own right. Sorry, but your comment isn't really helpful. – CraigD Jul 02 '19 at 07:04
  • AusPost says [3004 is also a physical address within Melbourne](http://auspost.com.au/postcode/melbourne), and Google's geocoder has a more colloquial understanding that more matches how a human would think - "I live in Melbourne, Australia" encompasses a lot more than just a tiny bit in the city center. – ceejayoz Jul 02 '19 at 13:35

1 Answers1

0

Since many cities span multiple postal codes, you probably need your users to provide the exact street address where they need service. Fearing the tedium of entering a full street address? Fear not; Place Autocomplete can save them many keystrokes especially if you constrain results to a specific country or location bounds.

You might want to create an address form and use Places Autocomplete to auto-fill the components including postal code once the user selects the address from autocomplete predictions. This section of the documentation demonstrates how it works and this page provides sample Javascript code for implementing an auto-completing address form.

devangela
  • 103
  • 4