【发布时间】:2012-03-16 20:50:37
【问题描述】:
我正在尝试使用 xcode 实现 google 的地理位置。当我传递带有纬度和经度的url时,它返回以下结果
<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
<status>ZERO_RESULTS</status>
</GeocodeResponse>
但是当我直接浏览网址时。它给出了正确的结果。 示例网址:http://maps.googleapis.com/maps/api/geocode/xml?latlng=68.56066,76.8803&sensor=true
coord.latitude = 68.56066;
coord.longitude = 76.8803;
NSString *urlStr = [NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/geocode/xml?latlng=%f,%f&sensor=true",coord.latitude,coord.longitude];
NSURL *url = [NSURL URLWithString:urlStr];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
NSData *xmlData = [NSData dataWithContentsOfURL:url];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
NSString *str = [[NSString alloc]initWithData:xmlData encoding:NSUTF8StringEncoding];
NSLog(@"XML Data is %@",str);
我需要获取 xml 结果。我的代码有问题吗。当我在谷歌网站上检查 ZERO_RESULTS 时。他们是这样提的..
ZERO_RESULTS 表示搜索成功但未返回任何结果。如果搜索是在远程位置传递的,则可能会发生这种情况。
任何想法...
【问题讨论】:
标签: iphone objective-c google-maps xml-parsing