美文网首页
Ios 应用内唤起百度地图APP的方式

Ios 应用内唤起百度地图APP的方式

作者: 景超叔叔 | 来源:发表于2016-09-01 11:44 被阅读786次
   UIWebView *webview = [[UIWebView alloc]init];
   webview.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
   //唤起百度地图APP  方式一
   NSString *strOrigin = @"34.2043700000,109.0071120000";
   NSString *strDestination = @"34.2069970000,108.9362530000";
   NSString *urlFirst =[NSString stringWithFormat:@"baidumap://map/direction?origin=%@&destination=%@&mode=driving&src=webapp.navi.yourCompanyName.yourAppName",strOrigin,strDestination];
   
   //加载页面 显示地图页面,再主动点击唤起百度地图APP 方式二
   NSString *originFrom = @"34.1986380000,108.8931260000";
   NSString *urlSecon = [[NSString stringWithFormat:@"http://api.map.baidu.com/direction?origin=latlng:%@|name:我的位置&destination=大雁塔&mode=driving&region=西安市&output=html",originFrom] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
   
   //    NSURL *url = [NSURL URLWithString:urlFirst];// 一
   NSURL *url = [NSURL URLWithString:urlSecon];// 二
   NSURLRequest *request = [[NSURLRequest alloc]initWithURL:url];
   [webview loadRequest:request];
   [self.view addSubview:webview];

相关文章

网友评论

      本文标题:Ios 应用内唤起百度地图APP的方式

      本文链接:https://www.haomeiwen.com/subject/cobcettx.html