【问题标题】:Get text description of region from GPS coordinates从 GPS 坐标中获取区域的文本描述
【发布时间】:2011-09-19 08:03:12
【问题描述】:

我在 iOS 中使用核心位置来获取 GPS 坐标。我想获得这些坐标所在的一般区域的一些人类可读的文本描述。我可以在设备本身本地执行此操作,也可以在我提交坐标的基于 PHP 的网站上执行此操作。

有什么想法吗?

【问题讨论】:

    标签: php ios gps


    【解决方案1】:

    您可以创建 URL 来检索一组坐标的文本描述,如下所示:

    http://maps.google.com/maps/geo?q="latitude","longtitude"&output=csv&sensor=false

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

    【讨论】:

    • 您好,感谢您的回答。我选择了另一个,因为它更具体到我的 iOS 任务,但你的回答也很有用,所以我也给了你道具。再次感谢。
    【解决方案2】:

    【讨论】:

    【解决方案3】:

    我在我的应用程序中使用 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];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-02
      • 1970-01-01
      • 1970-01-01
      • 2014-07-09
      相关资源
      最近更新 更多