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®ion=西安市&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];
网友评论