Search code examples
google-mapsgoogle-maps-api-3google-geocoderpostal-code

Google Geocoder returns incomplete zipcode


I am using the google geocoder to check if the address a user has entered is correct. For example, the user enters correct street and city name but wrong zip code. I want to check if the zip code from google is different than the one entered and display a suggestion. But this is not working for Brazil, Netherlands and other countries. For example, a valid Brazil zip code is 01421-020 but when I send this, the geocoder returns only 01421. This is happening for other countries also. Why is google not returning the full zip code?

Edit: I am using this package: https://github.com/geocoder-php/Geocoder When I try to submit this address:

R. Pedroso, 215, São Paulo 01322-010

the executed query link is: https://maps.googleapis.com/maps/api/geocode/json?address=R.%20Pedroso%2C%20215%2001322-010%20S%C3%A3o%20Paulo&sensor=false&language=pt_BR&region=BR if you click it, you can see the returned zip code in the result is 01322 without the -010 at the end


Solution

  • I am not too familiar with Brasilian postal codes, but if I understand correctly your 8 digit postal code would be analogous to our +4 zip codes here in the United States. Most mail here in the US is only addressed with a 5 digit zip code, for example 95014, even though the full zip code might by 95014-7845. The USPS will still deliver this mail, and the +4 codes are not used very often.

    It looks like Google does not support full 8 or 9 digit postal codes (even here in the US), I assume this either because they believe the extra digits are not necessary or they do not have access to the data.