Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone iOS-获取长/宽的地址_Iphone_Ios_Geocoding - Fatal编程技术网

Iphone iOS-获取长/宽的地址

Iphone iOS-获取长/宽的地址,iphone,ios,geocoding,Iphone,Ios,Geocoding,我想知道是否有人知道如何获得一个经纬度附近的地址列表 我一直在使用以下代码,但它总是产生一个地址: [self.geocoder reverseGeocodeLocation: currentLocation completionHandler: ^(NSArray *placemarks, NSError *error) { for (int i = 0; i < placemarks.count; i++) { CLPlacemark *pla

我想知道是否有人知道如何获得一个经纬度附近的地址列表

我一直在使用以下代码,但它总是产生一个地址:

[self.geocoder reverseGeocodeLocation: currentLocation  completionHandler:
 ^(NSArray *placemarks, NSError *error) {
     for (int i = 0; i < placemarks.count; i++)
     {
         CLPlacemark *placemark = [placemarks objectAtIndex:i];
         if (placemark.addressDictionary != nil)
         {
             Location *aLocation = [[Location alloc] init];
             aLocation.locationName = [placemark.addressDictionary valueForKey:@"Name"];
             aLocation.locationAddress = [placemark.addressDictionary valueForKey:@"City"];
             aLocation.currentLocation = placemark.location;
             [self.tableData addObject:aLocation];
         }
     }
    [self.locationsTableView reloadData];
 }];
[self.geocoder reverseGeocodeLocation:currentLocation completionHandler:
^(NSArray*放置标记,NSError*错误){
对于(int i=0;i
我不确定核心位置的地理编码是否打算这样做

谷歌允许这种搜索,但其PlacesAPI有一定的限制。也就是说,你可以搜索像“比萨饼”这样的东西,并在半径范围内得到结果

有关更多信息,请参阅:

您可以使用他们的API基于lat/long进行查询,并使用搜索查询和radius来获得与您所追求的结果类似的结果


祝你好运

首先更改您的纬度和经度值(检查您的代码是否正确),因为在地图中,某些坐标不能提供完整信息

如果某个坐标未提供完整信息,那么如何为您提供获取特定城市(或其他信息)名称的条件,下面提供代码。
这里是由
[self-getReverseGeocode]调用的
getReverseGeocode
方法

- (void) getReverseGeocode
    {
        CLGeocoder *geocoder = [[CLGeocoder alloc] init];

        if(currentLatLong.count > 0)
        {
            CLLocationCoordinate2D myCoOrdinate;

            myCoOrdinate.latitude = LatValue;
            myCoOrdinate.longitude = LangValue;

            CLLocation *location = [[CLLocation alloc] initWithLatitude:myCoOrdinate.latitude longitude:myCoOrdinate.longitude];
            [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error)
             {
                 if (error)
                 {
                     NSLog(@"failed with error: %@", error);
                     return;
                 }
                 if(placemarks.count > 0)
                 {
                     NSString *MyAddress = @"";
                     NSString *city = @"";

                     if([placemark.addressDictionary objectForKey:@"FormattedAddressLines"] != NULL)
                         MyAddress = [[placemark.addressDictionary objectForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];
                     else
                         MyAddress = @"Address Not founded";

                     if([placemark.addressDictionary objectForKey:@"SubAdministrativeArea"] != NULL)
                         city = [placemark.addressDictionary objectForKey:@"SubAdministrativeArea"];
                     else if([placemark.addressDictionary objectForKey:@"City"] != NULL)
                         city = [placemark.addressDictionary objectForKey:@"City"];
                     else if([placemark.addressDictionary objectForKey:@"Country"] != NULL)
                         city = [placemark.addressDictionary objectForKey:@"Country"];
                     else
                         city = @"City Not founded";

                   NSLog(@"%@",city);
                   NSLog(@"%@", MyAddress);
                 }
             }];
        }
    }

检查这个问题,你要找什么样的地址?你想要所有的邮寄地址还是仅仅是特定的地标(地点)?你知道它是否会根据我提供的长/宽给我X个位置吗?是的,我想这就是重点。您必须阅读文档,但如果需要,可以限制返回的位置数量。