Sreekrishnan
Sreekrishnan

Reputation: 179

Google Maps API Geocode not returning results on passing postal code as a value to address param

On trying to search a particular address by postal code(2000) it does not return the expected formatted address correctly, but whereas on searching using the address(frederiksberg) instead of postal code it returns the expected formatted address correctly.

https://maps.googleapis.com/maps/api/geocode/json?address=2000&components=country:Denmark&key=apikey

https://maps.googleapis.com/maps/api/geocode/json?address=frederiksberg&components=country:Denmark&key=apikey

But for a similar search with address set to postal code(4000) it returns the expected formatted address correctly, url below.

https://maps.googleapis.com/maps/api/geocode/json?address=4000&components=country:Denmark&key=apikey

Please let us know why its not returning the expected formatted address for address set to 2000.

TIA!

Upvotes: 6

Views: 4157

Answers (2)

camila
camila

Reputation: 99

We experienced a similar issue with Postcode 2000 in Australia (which is Sydney), returned OK but with Zero_Result returned. All the other postcodes worked fine except 2000

Our initial search was

geocode({ address: "2000 Australia", region: "AU" })

We solving it by adding "Postcode" before the search

geocode({ address: "Postcode 2000 Australia", region: "AU" })

Upvotes: 9

Ervin Ruci
Ervin Ruci

Reputation: 929

The Zip code 2000 matches more than one address. You can get the most common ones this way:

https://geocode.xyz/2000?region=DK

output:

Denmark x,y z: 55.68132,12.52966

🇩🇰 3 Solbjerg Plads, Frederiksberg C, Denmark » Confidence Score: 0.5

  • Frederiksberg DK 2000 Denmark
  • Frederiksberg Kommune DK 2000 Denmark
  • Brønshøj DK 2000 Denmark
  • Bronshoj DK 2000 Denmark
  • Frederiksberg C DK 2000 Denmark

Or in json format:

https://geocode.xyz/2000?region=DK&json=1

Json Output:
{
"standard": {
"addresst": "3 Solbjerg Plads",
"stnumber": "3",
"prov": "DK",
"city": "Frederiksberg C",
"countryname": "Denmark",
"postal": "2000",
"confidence": "0.5"
},
"longt": "12.52966",
"alt": {
"loc": [
  {
    "longt": "12.51635",
    "city": "Frederiksberg",
    "cc": "6353",
    "latt": "55.68239"
  },
  {
    "longt": "12.51704",
    "city": "Frederiksberg Kommune",
    "cc": "5629",
    "latt": "55.68255"
  },
  {
    "longt": "12.50332",
    "city": "Bronshoj",
    "cc": "2",
    "latt": "55.67113"
  },
  {
    "longt": "12.50332",
    "city": "Bronshoj",
    "cc": "2",
    "latt": "55.67113"
  },
  {
    "longt": "12.52966",
    "city": "Frederiksberg C",
    "cc": "1",
    "latt": "55.68132"
  }
]
},
"latt": "55.68132"
}

Upvotes: -2

Related Questions