首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google地图API错误:“Google is deprecated”

Google地图API错误:“Google is deprecated”
EN

Stack Overflow用户
提问于 2013-08-22 13:31:20
回答 3查看 126关注 0票数 0

我的代码总是给我一个“giving code is deprecated”的错误,我不知道如何修复它。这个应用程序一直把我带到谷歌地图,并在0.0纬度,0.0经度显示海洋的中心。这就是我现在拥有的代码。

代码语言:javascript
复制
NSString *locationStr = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlStr]];
NSLog(@"locationstr:%@",locationStr);
NSArray *items = [locationStr componentsSeparatedByString:@","];

double lat = 0.0;
double lon = 0.0;

if([items count] >= 4 && [[items objectAtIndex:0] isEqualToString:@"200"]) {
    lat = [[items objectAtIndex:2] doubleValue];
    lon = [[items objectAtIndex:3] doubleValue];
} else {
    NSLog(@"Address, %@ not found: Error %@",addressStr, [items objectAtIndex:0]);
}
NSLog(@"latlonislatlon:%.12f,%.12f,urlstr:%@",lat,lon,urlStr);
CLLocationCoordinate2D location;
location.latitude = lat;
location.longitude = lon;

谢谢你的帮助!

EN

回答 3

Stack Overflow用户

发布于 2013-08-22 13:35:33

它已被替换为

代码语言:javascript
复制
stringWithContentsOfURL:encoding:error: 

代码语言:javascript
复制
stringWithContentsOfURL:usedEncoding:error:
票数 0
EN

Stack Overflow用户

发布于 2013-08-22 13:36:45

因为纬度和经度的变量都被设置为0.0。

票数 0
EN

Stack Overflow用户

发布于 2013-08-22 13:36:49

使用此选项删除弃用警告

代码语言:javascript
复制
NSString *locationStr = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlStr] encoding:NSUTF16BigEndianStringEncoding error:nil];

也可以尝试使用不同lat,因为它们可能与lat有问题

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18372315

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档