【问题标题】:Finding place name from google Place search从谷歌地方搜索中找到地名
【发布时间】:2013-05-21 12:21:22
【问题描述】:

我想从 lat 和 long 中找到地名。我正在使用 google place api。 我怎样才能做到这一点

现在我可以用这个来搜索附近的纬度和经度了

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=AddYourOwnKeyHere

【问题讨论】:

    标签: objective-c google-maps google-places-api


    【解决方案1】:

    您可以使用 MKReverseGeoCoder 获取给定纬度和经度的名称、地区、信息等。但是,请注意它已被弃用。

    ViewController 应该是 MKReverseGeocoderDelegate 的委托。 MKReverseGeoCoder 的一个示例用法是;

    - (void)viewDidLoad {
        CLLocationCoordinate2D coordinates;
    
        coordinates.latitude = 33.8670522;
        coordinates.longitude = 151.1957362;
    
        CLLocation *location = [[CLLocation alloc] initWithLatitude:coordinates.latitude longitude:coordinates.longitude];
    
        MKReverseGeocoder* rev = [[MKReverseGeocoder alloc] initWithCoordinate:location.coordinate];
        rev.delegate = self;
        [rev start];
        [super viewDidLoad];
    }
    
    - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error {
        NSLog(@"Error with reverse geo coder.");
    }
    
    - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {
    
        NSLog(@"Geo coder finished successfully");
    
        NSString *administrativeArea = placemark.administrativeArea;
        NSString *thoroughfare = placemark.thoroughfare;
    
        NSLog(@"%@ %@", administrativeArea, thoroughfare);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-10
      • 1970-01-01
      • 1970-01-01
      • 2016-02-16
      • 1970-01-01
      • 2012-10-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多