如何使用MAPS API的OptimizeWaypoints配置重定向到地图页面?
我在我的应用程序中使用地图 api,当我要查看创建的路线时,我可以选择设置 optimizeWaypoints = true 来组织航路点,但是...我需要在谷歌地图页面上查看该路线,但每当我尝试时路径点没有“优化”。
我是这样做的:
for (var i = 0; i < wayptss.length; i++) {string_de_waypoints += wayptss[i] + '/';} var addresses = string_de_waypoints;
var address2 = document.getElementById("end").value;
// window.open("https://maps.google.ch/maps?saddr=["+address1+"]&daddr=["+address2+"] to:["+address3+"] to: ["+address4+"]to: ["+address5+"]")
link_maps = "https://www.google.ch/maps/dir/"+address1+"/"+addresses+address2;
window.open(link_maps)
值来自这里:
const waypts = [];
const checkboxArray = document.getElementById("waypoints");
wayptss=[];
for (let i = 0; i < checkboxArray.length; i++) {
if (checkboxArray.options[i].selected) {
waypts.push({
location: checkboxArray[i].value,
stopover: true,
});
//-----------------HERE--------------------------------
wayptss.push(checkboxArray[i].value,
);
}
好吧..我想知道的是,我是否有办法做到这一点,例如直接将路线导出到谷歌地图或类似的东西。 或者,如果不是至少一种通过获取他的距离或类似的东西来优化路线航点数组的方法。
I'm using maps api in my app and when i what to see the created route i have the choice of set optimizeWaypoints = true to organize the waypoints but... I need to see that route on google maps page, but whenever i try that the way points are not "optimized".
I have done this that way:
for (var i = 0; i < wayptss.length; i++) {string_de_waypoints += wayptss[i] + '/';} var addresses = string_de_waypoints;
var address2 = document.getElementById("end").value;
// window.open("https://maps.google.ch/maps?saddr=["+address1+"]&daddr=["+address2+"] to:["+address3+"] to: ["+address4+"]to: ["+address5+"]")
link_maps = "https://www.google.ch/maps/dir/"+address1+"/"+addresses+address2;
window.open(link_maps)
The value come from here:
const waypts = [];
const checkboxArray = document.getElementById("waypoints");
wayptss=[];
for (let i = 0; i < checkboxArray.length; i++) {
if (checkboxArray.options[i].selected) {
waypts.push({
location: checkboxArray[i].value,
stopover: true,
});
//-----------------HERE--------------------------------
wayptss.push(checkboxArray[i].value,
);
}
Well... What i want to know is, if I have some way to do that like exporting directly the route to google maps or something like that.
Or if not at least a way to optimize the route waypoints array by getting his distance or something like that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我找到了解决方案。
我用过这个:
https://developers.google.com/maps/documentation/javascript/方向
Ok i found a solution.
I used this:
https://developers.google.com/maps/documentation/javascript/directions