iOS - 百度地图

        NSString *baiduURLSchemes = [NSString stringWithFormat:@"baidumap://map/geocoder?address=%@&output=html&src=ruifeng", address];
        // 若不 encoding,返回的 URL 为空值
        NSURL *baiduURL = [NSURL URLWithString:[baiduURLSchemes stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        // 调用‘百度地图app’客户端
        if ([[UIApplication sharedApplication] canOpenURL:baiduURL]) {
            [[UIApplication sharedApplication] openURL:baiduURL];
        }else{
            //调用百度地图网页版
            NSURL *aURL = [NSURL URLWithString:[[NSString stringWithFormat:@"http://api.map.baidu.com/geocoder?address=%@&output=html&src=ruifeng", address] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            [[UIApplication sharedApplication] openURL:aURL];
        }

 

posted @ 2013-12-13 16:10  有妄想症的猫zz  阅读(555)  评论(0编辑  收藏  举报