gpt4 book ai didi

javascript - 从 google map api v3 中删除路线

转载 作者:IT王子 更新时间:2023-10-29 03:11:59 26 4
gpt4 key购买 nike

我有一个使用 API v3 的谷歌地图,它获取从一个位置到另一个位置的方向。该应用程序运行良好,但获取方向的窗口是 map 上的叠加层。我希望如此,当此窗口关闭时,方向将从 map 中删除,但其他标记仍然存在。

我尝试了以下方法:

$('#content .close').live('click', function() {
$('#content').hide();
directionDisplay = new google.maps.DirectionsRenderer();
directionDisplay.suppressMarkers = true;
directionDisplay.setMap(map);
return false;
});

这似乎按预期隐藏了窗口,但对于从 map 中删除方向没有任何作用。

非常感谢任何帮助。

戴夫。

最佳答案

您可以将 DirectionsRenderer 的 map 绑定(bind)更改为“null”以移除方向覆盖

directionDisplay.setMap(null);

关于javascript - 从 google map api v3 中删除路线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5645920/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com