Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
178 views
in Technique[技术] by (71.8m points)

google geocoding api services with zip code 12593

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

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

1 Reply

0 votes
by (71.8m points)

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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...