将iPhone GPS转换为地址 [英] Convert iPhone GPS to address

查看:84
本文介绍了将iPhone GPS转换为地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在为我的公司研究一些不同的应用程序,这些应用程序都可以将您当前的GPS位置转换为地址。我一直在谷歌搜索和搜索堆栈,但我似乎无法在网上找到任何有用的信息告诉我如何实现这一目标。所以我的问题是这个;你好吗:

I have been researching a few different apps lately for my company which are all able to convert your current GPS location to an address. I have been googling and searching through the stack but I can't seem to find any helpful information on the net to tell me how to achieve this. So my question is this; how do you:

a)获取你当前的GPS坐标,然后将
b)转换成真实的地址,即街道号/名称,城市, country

a) get your current GPS coordinates and then
b) transform them into a real address i.e. street number/name, city, country

推荐答案


a)获取您当前的GPS坐标

a) get your current GPS coordinates

您需要使用CLLocationManager(您可能需要存储管理器以在不再需要时释放它) -

You need to use CLLocationManager for that (you may need to store manager to release it when it no longer will be needed) -

CLLocationManager* manager = [[CLLocationManager alloc] init];
manager.delegate = self;
//Set location manager's properties if needed
[manager startUpdatingLocation];

然后您的委托对象将能够在GPS位置更新(或未能做到)时接收消息:

Then your delegate object will be able to receive messages when GPS location updates (or fails to do that):

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error




b)将它们转换为真实地址

b) transform them into a real address

获得旅游地点的gps坐标后,您可以创建 MKReverseGeocoder 用于查询Google反向地理编码服务的对象。如果请求成功,地理编码器的委托将收到带有地址信息的 MKPlacemark 对象。

After you have gps coordinate of tour location you can create MKReverseGeocoder object to query google reverse geocoding service. If request succeeds geocoder's delegate will receive MKPlacemark object with address info.

这篇关于将iPhone GPS转换为地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆