How to convert postal code to city name, is there an API available? [closed]

吃可爱长大的小学妹 提交于 2019-11-29 07:05:09

问题


How to convert post code to city name, is there an API available?


回答1:


You need a service that does geocoding.


Yahoo's Geocoder API is getting much better results globally.

110021 is the postal code for New Delhi among several other places in the world.

This seems to get them all.


Google Maps API is another such service but I'm not happy with the geocoded results as I don't get all results back for 110021.

geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': '110021'}, function(results, status) {
    console.log(results);
});



回答2:


Two years later, IMO the Google Maps Geocoding API is the best way to go.

Just pass in the postal code as the address parameter:

http://maps.googleapis.com/maps/api/geocode/json?address=94043&sensor=false



回答3:


http://zipasaur.us/ is incredible and free. I just discovered it after quite some searching.

It can do reverse lookups like you ask and more. It's free and has a JSON API. Awesome!

[edit] It's down now and has been for quite some time. It was nice while it lasted though :(




回答4:


The US Post Office sells a subscription to map 5 digit zip codes to City/State values. As @Timothy says, the mapping is one to many. However, the post office db does mark which city/state is the "primary" for a given zip code.

Don't know about other countries. Check with your country's postal authority.

See http://www.usps.com/ncsc/addressinfo/citystate.htm




回答5:


RedLine offers a free zipcode API service (up to 250 requests per hour). There are 4 different varieties covering distances between two zipcodes, zipcodes within a radius of a zipcode, City, state and Lat/long of a zipcode and the zipcode of a city. http://zipcodedistanceapi.redline13.com/




回答6:


Just to put in my .02, using the Google Maps API mentioned above, you can look up global information. I am currently working on a project and am pretty much implementing it as my solution for this issue. Ok, off my tiny soap box.



来源:https://stackoverflow.com/questions/2846466/how-to-convert-postal-code-to-city-name-is-there-an-api-available

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