适用于多站的Google Maps URL架构 [英] Google Maps URL Schema for multi stops
问题描述
我想使用url方案在iOS上打开Google Maps应用,以显示具有多个停靠点的路线.
I would like to open Google Maps app on iOS using the url scheme for showing directions with multiple stops.
用于测试的网址是:
https://google.com/maps/dir//49.54643774,22.28223445/49.54679476,22.28170513/49.54726735,22.28154318/49.54760869,22.28156607/49.54820312,22.2815506/49.54856556,22.28146425/49.54907329,22.28133231/49.54989807,22.28207924/49.55017454,22.2824851/49.55064392,22.28306989/49.5508548,22.28325003/49.55143275,22.28381447/49.55169439,22.28410868/49.5520271,22.28443534
我使用comgooglemaps://
尝试了许多应用程序配置,但没有成功.
I tried many configurations of the app scheme using comgooglemaps://
without success.
推荐答案
您可以阅读用于打开该应用程序的Google Maps文档.
为简化起见,这是您需要遵循的格式:
To simplify it, this is the format you need to follow:
comgooglemaps://?saddr=Google,+1600+Amphitheatre+Parkway,+Mountain+View,+CA+94043&daddr=Google+Inc,+345+Spear+Street,+San+Francisco,+CA¢er=37.422185,-122.083898&zoom=10
您会迅速执行以下操作,注意回调选项,如果您不想返回到应用程序,则可以选择不使用它:
in swift you would do something like this, take note of the callback option, you can choose to not have it if you don't want to return to your app:
let testURL = URL(string: "comgooglemaps-x-callback://")!
if UIApplication.shared.canOpenURL(testURL) {
let directionsRequest = "comgooglemaps-x-callback://" +
"?daddr=John+F.+Kennedy+International+Airport,+Van+Wyck+Expressway,+Jamaica,+New+York" +
"&x-success=sourceapp://?resume=true&x-source=AirApp"
let directionsURL = URL(string: directionsRequest)!
UIApplication.shared.openURL(directionsURL)
} else {
NSLog("Can't use comgooglemaps-x-callback:// on this device.")
}
要使用坐标,请按以下方式使用它:
To use coordinates, use it this way:
comgooglemaps://?saddr=52.3668563,4.8890813&daddr=52.357516,4.902319&zoom=10
要获取地图上的更多点,请在daddr
参数上使用+to:Latitude,Longtitude
附加坐标
Edit 2: For for more points on the map append coordinate using +to:Latitude,Longtitude
to the daddr
parameter
comgooglemaps://?saddr=52.3668563,4.8890813&daddr=52.357516,4.902319+to:52.357786,4.891913&zoom=10
这篇关于适用于多站的Google Maps URL架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!