Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.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 通过CLGeocoder的方法查找区域中的所有位置_Iphone_Ios_Location_Clgeocoder - Fatal编程技术网

Iphone 通过CLGeocoder的方法查找区域中的所有位置

Iphone 通过CLGeocoder的方法查找区域中的所有位置,iphone,ios,location,clgeocoder,Iphone,Ios,Location,Clgeocoder,使用“–reverseGeocodeLocation:completionHandler:”方法对位置进行反向地理编码非常方便。但是如何获取一个区域中的所有位置 注:如果一个地区有几个地方。如何使用区域信息查找所有位置?例如,对一个位置进行反向地理编码,给定一个坐标,返回一个位置。这里我想给出一个区域,返回该区域中的所有位置。有一个google Geocoder API返回JSON,它只是一种使用GET方法的web服务 是Google Gecoder API,是该web服务的链接,在该链接中,我

使用“–reverseGeocodeLocation:completionHandler:”方法对位置进行反向地理编码非常方便。但是如何获取一个区域中的所有位置


注:如果一个地区有几个地方。如何使用区域信息查找所有位置?例如,对一个位置进行反向地理编码,给定一个坐标,返回一个位置。这里我想给出一个区域,返回该区域中的所有位置。

有一个google Geocoder API返回JSON,它只是一种使用GET方法的web服务

是Google Gecoder API,是该web服务的链接,在该链接中,我将区域名称命名为伦敦

注意:您需要在代码中包含SBJson库

在链接的末尾,我添加了地址,如果您添加了地址-您需要提供区域名称(或者)如果您添加了纬度和经度,您需要提供坐标,它将相应地返回结果

调用GoogleAPI的代码如下

                //Call the Google API
                NSString *req = [NSString stringWithFormat:@"http://maps.google.com/maps/api/geocode/json?sensor=false&address=%@", esc_addr];
                NSLog(@"The get address is %@", req);
                //Pass the string to the NSURL
                NSString *result = [NSString stringWithContentsOfURL:[NSURL URLWithString:req] encoding:NSUTF8StringEncoding error:NULL];
                NSLog(@"The result is %@", result);
                //Initialize the SBJSON Class
                SBJSON *parser = [[SBJSON alloc] init];
                NSError *error = nil;
                //Get the resullts and stored in the address array
                addressArray = [parser objectWithString:result error:&error];
                //Get the latitude values for the given address
                NSDictionary *dict = [[[addressArray valueForKey:@"results"] valueForKey:@"geometry"] valueForKey:@"location"];
                self.latitudeValue = [[dict valueForKey:@"lat"] objectAtIndex:0];
                self.longitudeValue = [[dict valueForKey:@"lng"] objectAtIndex:0];
                NSLog(@"LAT : %@",self.latitudeValue);
                NSLog(@"LONG : %@",self.longitudeValue);

请你说清楚一点好吗?