【问题标题】:WebKitErrorDomain error 101 (in mapview)WebKitErrorDomain 错误 101(在地图视图中)
【发布时间】:2011-09-28 11:37:41
【问题描述】:

这是我的代码,我得到了这个错误

NSString *url = [NSString stringWithFormat:@"%@?lat=%@&long=%@",
                 [[NSBundle mainBundle] pathForResource:@"map" ofType:@"html"],
                 @"17.734503", 
                 @"83.2999716"];

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
DirctionWeb.delegate = self;
[DirctionWeb loadRequest:request];

所以我在这里将网页连接到谷歌地图html页面为什么这个错误消息请指导我

【问题讨论】:

    标签: iphone


    【解决方案1】:

    确保 url 编码正确,并且在纬度和经度上有 +-,如下所示:

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://maps.google.com/?q=+17.734503,+83.2999716"]];
    DirctionWeb.delegate = self;
    [DirctionWeb loadRequest:request];
    

    所以,替换这个:

    NSString *htmlFile = [NSString stringWithFormat:@"%@?lat=%@&long=%@",
                     [[NSBundle mainBundle] pathForResource:@"map" ofType:@"html"],
                     @"17.734503", 
                     @"-83.2999716"];
    

    与:

    NSString *htmlFile = [NSString stringWithFormat:@"%@?lat=+.000000f&long=%+.000000f",
                     [[NSBundle mainBundle] pathForResource:@"map" ofType:@"html"],
                     @"17.734503", 
                     @"-83.2999716"];
    

    【讨论】:

    • 感谢您的回答...在这里我想将纬度和经度传递给 map.html 这是我的代码它不起作用请指导我 NSString *htmlFile = [NSString stringWithFormat:@"%@?lat =%@&long=%@", [[NSBundle mainBundle] pathForResource:@"map" ofType:@"html"], @"35.115403", @"-89.9045614724"];
    • 再次感谢我尝试你的代码我打印 NSLog(@"url is %@",htmlFile);我像这样得到 iClean.app/map.html?lat=+0&long=+0
    猜你喜欢
    • 2011-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多