Google地图替代路线不会更新 [英] Google maps alternative routes won't update

查看:109
本文介绍了Google地图替代路线不会更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了从一个点到多个特定点的方向图。当更改结束点时,地图应该更新,备用路线应显示在右侧边栏上,并在其下方有详细信息。然而,当我改变结束点时,它并没有很好地更新,有时它只是在旧方向下添加替代方向,有时候替代品会混乱,不确定问题是什么,尽管我怀疑如果没有问题为特定终点返回替代路线。以下是我到目前为止所做的预览:

I have created a directions map from one point to multiple specific point. When one change end point the map should update, and alternative routes should be shown on the right sidebar, with details under it. However, when I change end point it's not updating nicely, sometimes it just add alternative directions under "old" directions,sometimes alternatives are messed up, not really sure what the problem is, though I suspect that there might be a problem if theres's no alternative routes returned for the specific end point. Here's a preview of what I made so far:

jsbin.com/hoqebofice/edit?output  

另外,最后,我还希望一旦从右侧边栏点击替代路线,地图也会更新。

Also in the end, I'd like to have map updated once alternative route is clicked from the right sidebar as well.

推荐答案

在您的OnChangeHandler中添加以下行:

In your OnChangeHandler add this line:

 var onChangeHandler = function() {
      document.getElementById("setPanel").innerHTML = ""; // THIS ONE!
      calculateAndDisplayRoute(directionsService, directionsDisplay);
    };

这篇关于Google地图替代路线不会更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆