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

核能气质少年 提交于 2019-12-10 17:36:28

问题


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!


回答1:


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" })




回答2:


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"
}


来源:https://stackoverflow.com/questions/50037957/google-maps-api-geocode-not-returning-results-on-passing-postal-code-as-a-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!