Get zip code from latitude, longitude?

后端 未结 5 2006
长发绾君心
长发绾君心 2020-12-01 06:56

I want to get zip code from users current location(Latitude, Longitude), I had used MKReverse Geocoder delegate methods, but sometimes I am not able to get zip code informat

5条回答
  •  萌比男神i
    2020-12-01 07:37

    Consider the GeoNames web service. It's a complete geocoding/reverse geocoding suite under a Creative Commons attribution license. You can either download their data, or hit their web service. The best thing is, they don't require any API keys or licensing silliness--you just hit their web app and bang you got data.

    Here's an example: http://ws.geonames.org/findNearbyPostalCodesJSON?formatted=true&lat=36&lng=-79.08 That'll return you a JSON object for the zip codes around the Chapel Hill, NC area.

    It's also international. Here's Seaford, England, and the only difference is the lat/lng pair I'm sending: http://ws.geonames.org/findNearbyPostalCodesJSON?formatted=true&lat=50.5&lng=0.08

    Then you need to learn to make web requests and parse JSON (if you don't already have a grip on those things), and you're all set.

提交回复
热议问题