【问题标题】:Google place API for iOS适用于 iOS 的 Google Place API
【发布时间】:2012-05-23 16:43:37
【问题描述】:

我正在尝试查找带有商家名称的地点的位置。 我想我应该使用 Google Place API,因为 CLGeocoder 无法找到带有名称的地点。

所以我查看了 Google Place API,对位置字段的部分有点困惑。

我想我应该输入位置和半径以及可选的名称来搜索。

当我不知道位置时,我不确定应该输入哪个位置才能找到该位置。我想要的是从名称中搜索位置。

那么,我是否应该使用CLGeocoder 来找出大概位置并将该位置的巨大半径提供给 Google Place API?

例如,如果我想在洛杉矶找到某家酒店,那么我应该使用CLGeocoder 找出大概位置,然后将该值提供给 Google Place API 吗?

或者还有其他选择吗?

非常感谢您的帮助

【问题讨论】:

  • 您提到“对位置字段的部分感到困惑”,您指的是哪个google place API调用?

标签: iphone ios geocoding google-places-api clgeocoder


【解决方案1】:

您的方法很好 - 在我的一个应用程序中,您可以输入地址,输入地址后,我使用 CLGeoCoder 获取带有坐标的地标。

CLGeocoder *geoCoder = [[CLGeocoder alloc] init];
[geoCoder geocodeAddressString:addressString completionHandler:^(NSArray *placemarks, NSError *error) {

    if (placemarks && placemarks.count>0) 
    {
        if(placemarks.count==1)
        {
            MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([[[placemarks objectAtIndex:0] location] coordinate], 1000, 1000);

            [mapView setRegion:region animated:YES];
            [mapView regionThatFits:region];
        }
   }

地标具有可用于 google 地方 API 的属性坐标

【讨论】:

  • 当给定我的地址字符串时,它显示错误:Error Domain=kCLErrorDomain Code=8 "The operation could not be completed. (kCLErrorDomain error 8.)"
猜你喜欢
  • 2017-11-08
  • 2015-12-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-26
  • 1970-01-01
  • 2016-11-29
相关资源
最近更新 更多