- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用“–reverseGeocodeLocation:completionHandler:”方法对位置进行反向地理编码很方便。但是如何获取一个区域内的所有位置。
附言。如果一个地区有几个地方。我怎样才能使用区域信息找出所有的地方?比如反向地理编码一个位置,给定一个坐标,返回一个位置。这里我想给出一个区域,返回该区域中的所有位置。
最佳答案
有一个返回 JSON 的 google Geocoder API,它只是一种使用 GET 方法的网络服务
和This是 Google Gecoder API 和 This是该 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);
关于iphone - 通过 CLGeocoder 的方法查找一个区域中的所有位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10673912/
我有一个简单的问题。 MKReverseCoder 已弃用,自 iOS 5 起不再工作。我们必须使用CLGeocoder。但是,iOS4下有很多人。新应用程序如何与 iOS4 和 iOS5 一起使用进
我有一个应用程序可以进行正向地理编码(获取给定地址的坐标)以在 MKMapView 上显示一堆图钉。该应用程序是在 iOS 使用 CLGeocoder 支持正向地理编码之前开发的。 (首次在 iOS
我正在使用CLGeocoder来确定特定位置的地标的项目。 这样非常简单的调用。 CLGeocoder().geocodeAddressString(location) { (placemarks,
我正在尝试找出方法来限制我向 CLGeocoder 发出的请求数量,因为我不断超出最大限制。我得到“Error Domain=kCLErrorDomain Code = 2”(null)”。基本上,每
documentation CLGeocoder 状态: An iOS-based device must have access to the network in order for the ge
我没有在文档中看到任何明确提及的内容: https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLG
您好,我正在使用此方法来获取坐标并向 map View 添加一个邮政编码的图钉 -(void)myMapview { //sitePC is an Array with the Post co
在模拟器中我将位置设置为 Latitude: 38.056709 Longitude: -78.6115 但返回的地标是弗吉尼亚州的。 CLGeocoder *geocoder = [[CLGeoco
在我的 viewDidLoad 中,我有这个方法,可以将 Parse 中的位置转换为城市和州。唯一的问题是,大多数时候它以错误的顺序附加。另外,位置变量末尾的 .location 是一种自定义方法,可
我正在尝试使用由 URL 和城市名称组成的字符串发出 http 请求,使用 CLGeocoder 获取用户的当前位置,然后返回他们所在城市的名称。 string 在调用之前生成,并使用 + 运算符连接
我正在使用 CLGeoCoder 进行正向地理编码。它在 OS > 5.0 的设备中运行良好。 但是应用程序崩溃是操作系统 : dyld: Symbol not found: _OBJC_CL : A
所以我试图让它在完成处理程序之后做一些事情,但我一直收到错误: expected CLGeocodeCompletionHandler class func didCompleteGeocoding(
我正在 iOS 8.0 中开发应用。 通过下面的链接,我正在分配位置对象, How can I get current location from user in iOS 我的目标是根据当前位置找出城
我正在使用 CLGeocoder 在 map 上定位地址并计算用户与一大堆地址的距离。 这是使用 CLGeocoder 的代码部分: CLGeocoder *geocoder = [[CLGeocod
我正在使用 CLGeocoder reverseGeocodeLocation 从坐标中获取地址,似乎在中国返回“地理编码器失败:错误域=kCLErrorDomain 代码=8”操作无法完成。 (kC
我正在为 IOS5 开发一个 iPhone 应用程序。我目前正在使用位于 CoreLocation 框架内的 CLGeocoder 类。我无法弄清楚完成处理程序 block 是否在最后调用,在地理编码
给定经度和纬度不是我的当前位置,我如何使用 GLGeocoder 执行反向地理编码查找? self.geoCoder = [[CLGeocoder alloc] init]; self.locatio
我要复活this和 this问题,因为问题对我来说仍然存在,所以我正在写一个新问题。 这是我的代码: - (SVGeocoder*)initWithParameters:(NSMutableDicti
谁能帮我理解为什么下面的代码会有这样的输出: [ +/- 5.00m (speed 32.65 mps / course 294.26) @ 7/27/16, 4:34:19 AM Eastern D
我在使用 CLGeocoder 时遇到问题,当我调用 geocodeAddressString:withCompletionHandler 时,我只得到一个结果,尽管我知道输入的字符串应该返回多个值。
我是一名优秀的程序员,十分优秀!