2010-04-22 71 views
2

我一直在爲我的公司研究幾種不同的應用程序,它們都能夠將您當前的GPS位置轉換爲地址。我一直在谷歌搜索和搜索堆棧,但我似乎無法找到任何有用的信息在網絡上告訴我如何實現這一目標。所以我的問題是這樣的;你怎麼了:將iPhone GPS轉換爲地址

一)讓您當前的GPS座標,然後
二)將其轉化爲一個真正的地址,即街道號碼/名稱,城市,國家

回答

1

a)得到您當前的GPS座標

您需要使用CLLocationManager爲(您可能需要存儲管理員將其釋放時,將不再需要它) -

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

那麼你的委託對象將能接收消息時,GPS位置更新(或未能做到這一點):

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

二)將其轉化爲實際地址

你有旅遊地點GPS系統座標後,你可以創建MKReverseGeocoder對象來查詢谷歌反向地理編碼服務。如果請求成功,geocoder的代表將收到地址信息的MKPlacemark對象。