这是我用来打开谷歌地图的一个单站:
$(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
以使多个停止路由?
您可以通过以下格式添加多个止点:
https://www.google.com/maps/dir/${START}/${STOP1}/${STOP2}/${END}
.
您可以随意添加站点。