从google map api v3中删除路线 [英] Remove directions from google map api v3

查看:88
本文介绍了从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);

这篇关于从google map api v3中删除路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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