简体   繁体   English

在Xcode中在Google地图上的两个协调之间绘制路线

[英]Draw route between two coordination on google maps in Xcode

Actually I'm stuck in a simple problem for about two days. 实际上,我在一个简单的问题中停留了大约两天。

I want to draw a route between my location and another location on Google maps. 我想在我的位置和Google地图上的另一个位置之间绘制一条路线。

I am using Google map sdk and I've read every question available on Stackoverflow but I had no chance achieving this. 我正在使用Google map sdk,并且已经阅读了Stackoverflow上的所有可用问题,但我没有实现这一目标的机会。

I know I should send a request to some Google API and parse the json, but I don't know how to parse that json and then unseeing that data to draw route on map. 我知道我应该向某个Google API发送请求并解析json,但是我不知道如何解析该json,然后看不到该数据以在地图上绘制路线。

any link or piece of code appreciated! 任何链接或一段代码表示赞赏!

actually there is a way without using google sdk or googlemaps framework take a webview and you have to call a url that is..... 实际上,有一种方法无需使用google sdk或googlemaps框架即可获取网络视图,而您必须调用的网址是.....

if ([[UIApplication sharedApplication] canOpenURL:url]){
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://maps.google.com/maps/place/%@", location]]];
    [businessLocationWebView loadRequest:request];
}

then it will show the location you entered. 然后它将显示您输入的位置。 There u will see the view like this 在那里你会看到这样的景色 谷歌地图页面

there u can find the route from your location to a specified location entered in the textfield 在这里,您可以找到从您的位置到在文本字段中输入的指定位置的路线

Happy coding 快乐编码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM