0

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

  • Can you provide an example request? Just sending a raw postal code will not work well, as this would be very hard to correctly interpret even for humans... – mensi Nov 05 '14 at 13:14
  • It is returning a partial match. If you remove the street number it finds an exact match, and returns the full postal code. – Gabriele Petrioli Nov 05 '14 at 14:53
  • @GabyakaG.Petrioli this actually works, but I need the street number, because the system I am working on provides home services and we need a detailed address. Any idea why Google is returning only partial zip code when provided the street number? –  Nov 05 '14 at 15:15
  • Not sure how foolproof it would be, but you might want to do a second request if you get a `postal_code_prefix` in your `address_components`. One without the street number (*just to get the full postal code*). – Gabriele Petrioli Nov 05 '14 at 15:38
  • @faust, have you ever managed to geocode SP-capital zipcodes (5 digits)? I cannot geocode zipcodes like "sao paulo 01000" because google thinks it is a street number – Fernando Fabreti Apr 24 '15 at 12:22

1 Answers1

3

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.

Voltin
  • 158
  • 1
  • 10