2011-06-21 19 views
0

GPS座標を取得するためにiOSでコアロケーションを使用しています。私は、これらの座標がある一般的な領域の人間が読めるテキストの説明を得たいと思います。私はこれを、ローカルで、または自分が座標を送信しているPHPベースのウェブサイト上でローカルで行うことができます。GPS座標からの地域のテキストの説明を取得

アイデア?

答えて

2

あなたがMKReverseGeocoderを使用して、デバイス自体にIOSで逆ジオコーディングを行うことができます。http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKReverseGeocoder_Class/Reference/Reference.html#//apple_ref/occ/cl/MKReverseGeocoder

あなたは、いくつかのsample usage hereを見ることができます。

+0

GoogleマップAPIを使用します。 Yahooは同様のサービスを提供しています - http://developer.yahoo.com/geo/geoplanet/guide/concepts.html – symcbean

3

あなたは、このような座標のセットのテキストdesription取得するために、URLのを作成することができます。

http://maps.google.com/maps/geo?q= "緯度"、 "経度" &出力= CSV &センサーを=偽

EG http://maps.google.com/maps/geo?q=37.42228990140251,-122.0822035425683&output=csv&sensor=false

+0

こんにちは、ありがとうございます。私はiOSのタスクに固有のものだったので、もう1つを選んだのですが、あなたの答えも役に立ちました。再度、感謝します。 – gonzobrains

0

私のアプリでCLLocationManagerDelegateとMKReverseGeocoderDelegateを使用します。 CLLocationManager * locationManagerを作成し、そのプロパティと精度を設定してから開始します。

- (void)locationManager:(CLLocationManager *)manager 
     didUpdateHeading:(CLHeading *)newHeading 
{ 
    [manager stopUpdatingHeading]; 

    CLLocationCoordinate2D coordinate = manager.location.coordinate; 

    MKReverseGeocoder * geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:coordinate]; 
    geocoder.delegate = self; 
    [geocoder start]; 
} 

#pragma mark - MKReverseGeocoderDelegate 

あなたは位置情報でNSDictionaryを取得します。私はすべての鍵を使用していません。リストされているNSLOG辞書キーとそれに対応する値以上が必要な場合。 それがあなたを助けてくれることを願っています。

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark 
{ 
    getLocationState = glsAvailable; 

    NSDictionary * dic = placemark.addressDictionary; 

    NSString * CountryCode = [dic objectForKey:@"CountryCode"]; 
    NSString * State = [dic objectForKey:@"State"]; 
    NSString * City = [dic objectForKey:@"City"]; 
    NSString * SubLocality = [dic objectForKey:@"SubLocality"]; 
    NSString * Street = [dic objectForKey:@"Street"]; 
    NSString * ZIP = [dic objectForKey:@"ZIP"]; 

    self.locationString = [NSString stringWithFormat:@"%@ %@ %@ %@ %@ %@", 
          CountryCode?CountryCode:@"", 
          State?State:@"", 
          City?City:@"", 
          SubLocality?SubLocality:@"", 
          Street?Street:@"", 
          ZIP?ZIP:@"" 
          ]; 

    [[NSNotificationCenter defaultCenter] postNotificationName:@"LOCATION_STRING_IS_READY" object:nil]; 
    [geocoder cancel]; 
    [geocoder release]; 
} 
関連する問題