从google map api v3中删除路线

问题描述:

我有一个使用API​​ v3的谷歌地图,该地图从一个地方到另一个地方。该应用程序运行良好,但获取方向的窗口是地图上的叠加层。我想这样,当这个窗口关闭方向从地图中删除,但其他标记仍然存在。

I have a google map using API v3 which gets directions from one location to another. The app works great but the window which gets the directions is an overlay on the map. I'd like it so when this window is closed directions are removed from the map but other markers remain.

我试过以下内容:

I have tried the following:

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

这似乎隐藏了预期的窗口,但没有做任何关于从地图中删除路线的问题。

This seems to hide the window as expected but doesn't do anything regards with removing directions from the map.

任何帮助都非常感谢。

Dave。

Dave.

您可以将DirectionsRenderer的地图绑定更改为null以删除方向叠加

You can change the map binding for the DirectionsRenderer to "null" to remove the direction overlay

directionDisplay.setMap(null);