iOS 调用百度地图(网页和客户端两种)

论坛 期权论坛 脚本     
匿名技术用户   2020-12-28 22:28   11   0
  //判断有没有安装百度地图客户端
   if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"baidumap://"]]) {
          //百度地图app
           NSString *urlString = [[NSString stringWithFormat:@"baidumap://map/place/search?query=公交站&location=%@,%@&radius=1000&region=%@&src=幸福爱家",latitudeS,longitudeS,cityS] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
           [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
     }else{
            UIWebView *webview = [[UIWebView alloc]init];
            webview.frame = CGRectMake(0, 0, screenWidth,screenHeight-64);
            //webview.delegate=self;
            [self.view addSubview:webview];
    
            NSString *urlString = [[NSString stringWithFormat:@"http://api.map.baidu.com/place/search?query=公交&location=%@,%@&radius=1000&region=%@&src=项目名称&output=html",_latitude,_longitude,_cityStr] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
             NSURL *url = [NSURL URLWithString:urlString];
             [webview loadRequest:[NSURLRequest requestWithURL:url]];
                     
     }

               

转载于:https://my.oschina.net/wenchengxu123/blog/844371

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP