开发者

Determine if the iPhone is in the US or Canada?

开发者 https://www.devze.com 2023-03-04 21:44 出处:网络
I have two questions. In my app, I am getting the GPS coordinates of friends. How can I determine if those friends are in the US/Canada?

I have two questions. In my app, I am getting the GPS coordinates of friends. How can I determine if those friends are in the US/Canada?

The second question is to find out开发者_开发技巧 if the actual device is in the US/Canada?


The term for this is Reverse Geocoding. You want to have a look at the MKReverseGeocoder class and its sample code, this is Apple's solution for this. However, it requires you to display a map (which may or may not be what you want).

If you don't want the map then things get a little bit more complicated. See Offline Reverse Geocoding at Country Level and Techniques for offline reverse geocoding on a mobile device?.


You can use the Reverse Geocoding API of google to get the address corresponding to the coordinates and extract the country details from the response's address_components.

http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true

0

精彩评论

暂无评论...
验证码 换一张
取 消