Getting surrounding zip codes from a location using Apple Map Kit

99封情书 提交于 2020-01-10 06:12:46

问题


I'm getting started on Map Kit for my job and I have a IOS project I am working on where it involves Map Kit, I know how to search for a location and pin point it but my issues is that part of my project involves getting the next 10-15 zip codes of the surrounding areas of my central location and receive the cities that are in each zip code, i really don't know how to implement it and I need help. an explanation or a snippet of code would be much appreciated.


回答1:


Zip codes like this aren't available in MapKit. You need to find a third-party source of zip code data (e.g. codes + bounding geometries), figure out a way to index them (perhaps be using or precalculating the centroid of each), and then figure out what's close to the selected point.




回答2:


Use Google Places API for this.

You can go for a Radar or NearbyPlaces search and get zip codes of the returned places (you can use a custom location and set the radius for your search as you are wishing to do).

There is a really good iOS library for querying Google Places API which is FTGooglePlacesAPI

Eventually you can also do everything manually using

NSData* data = [NSData dataWithContentsOfURL:YOUR-googleRequestURL];

and handling the fetched data.



来源:https://stackoverflow.com/questions/26948207/getting-surrounding-zip-codes-from-a-location-using-apple-map-kit

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