문제

I need to programmatically find approximate postal/zip code for a given city. When I use this link:

http://maps.googleapis.com/maps/api/geocode/xmladdress=vancouver,BC,Canada&components=country:CA

it brings me all location information except postal code. Is there a way to get a postal code using only city name?

도움이 되었습니까?

해결책 2

I have looked around a lot. Ben is right. It is not possible to get postal codes by using only city names. You need full address. However you can get postal code of a coordinate. It requires too many api calls but if you have the coordinates of the city you can get the postal code easily.

다른 팁

Likely not, as cities can have multiple zip codes.

At least for the US, you could look at the "Hold For Pickup Facility Information" api from the USPS

https://www.usps.com/business/web-tools-apis/address-information.htm (scroll down a bit)

This returns a list of us postal facilities in a given city, from which you could glean a list of (at least some) zip codes in the area.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top