使用“ - ReverseGeocodeLocation:CompletionHandler:”方法来反转地理编码位置的方法。但如何在区域中获得所有位置。

ps。如果一个地区有几个地方。如何使用该区域信息来查找所有地点?例如反向地理编码位置,给定坐标,返回位置。在这里我想给一个地区,返回该地区的所有位置。

有帮助吗?

解决方案

有一个谷歌地理域API返回JSON,这只是一种使用Get方法的Web服务

这个是google gecoder api和这个是该Web服务的链接,在此链接中我给出了区域名称作为伦敦。

注意:您需要将sbjson库纳入代码。

在该链接结束时,我已经附加地址,如果您附加地址 - 您需要给出区域名称(或)如果您附加纬度和经度,则需要给出坐标,它将相应地返回结果。

和呼叫Google API的代码将是这样

                //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);
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top