Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am having an issue with google geo-loaction services. essentially we are using it for a zip code validator and there is an issue with zip code '12593'. This zip code is showing as being in Spain. (see screenshot here = http://prntscr.com/hkkafh.

See xml here https://maps.googleapis.com/maps/api/geocode/xml?&address=12593)

This zip code though is a USA based zip code as can be seen here = https://www.google.com/search?num=100&q=us+zip+code+12593&oq=us+zip+code+12593 (google search results.)

I understand that google is not the othority on zip codes however I would expect google to understand that this zip code may have two seperate locations.

any idea How I can get the api to understand I am looking for zip codes specifically in the USA?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
168 views
Welcome To Ask or Share your Answers For Others

1 Answer

The zip code you're trying to find isn't reachable by the geocoding api. This near one is reachable:

https://maps.googleapis.com/maps/api/geocode/json?&components=country:US|postal_code:12516

To search by zip code and restrict by country (i.e. US), you must use the subparameters of the components query parameter like in the URL above

...&components=country:US|postal_code:[YOUR PARAMETER]

(got this parameter info on https://developers.google.com/maps/documentation/geocoding/intro#ComponentFiltering)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...