【问题标题】:How to open google maps with multiple stops in web app?如何在网络应用程序中打开多个站点的谷歌地图?
【发布时间】:2021-12-08 01:52:48
【问题描述】:

这是我用来单站打开谷歌地图的方法:

$(document).on('click', 'button', function () {
    const location = "Empire state building"
    const location2 = "Washington square park"

var url = `https://www.google.com.sa/maps/search/${location}?hl=en`

window.open(url, '_blank');

});
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
</head>
<body>
<button>OPEN GOOGLE MAPS</button>
</body>
</html>

如何在 url 中包含 location2 以制作多站路线?

【问题讨论】:

    标签: javascript html jquery google-maps google-maps-api-3


    【解决方案1】:

    您可以通过以下格式添加多个站点:

    https://www.google.com/maps/dir/${START}/${STOP1}/${STOP2}/${END}.

    您可以添加任意数量的站点。

    【讨论】:

    • 酷,你知道我怎样才能自动将开始设置为当前位置吗?
    • @VaggelisNos 您可以将 start 留空,以便用户自己输入。喜欢:https://www.google.com/maps/dir//${STOP1}/${STOP2}/${END}。注意双 /
    猜你喜欢
    • 2012-09-10
    • 2019-08-16
    • 1970-01-01
    • 1970-01-01
    • 2012-10-16
    • 2012-02-23
    • 1970-01-01
    • 1970-01-01
    • 2018-03-07
    相关资源
    最近更新 更多