开发者

Determine if the iPhone is in the US or 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜