【问题标题】:how to hide markers from DirectionsService's DirectionsRoute object in google maps api v3?如何在谷歌地图 api v3 中隐藏 DirectionsService 的 DirectionsRoute 对象中的标记?
【发布时间】:2011-07-27 07:22:22
【问题描述】:

在 google maps api v3 中,我认为您无法再获取地图对象上的所有标记。我需要从 DirectionsService 结果中隐藏最后一个标记。我以前可以在 v2 中做到这一点:

_gdir.getMarker(_gdir.getNumRoutes()).hide();

我有在同一个地方开始和结束的路线,我需要隐藏最后一个标记,这样它就不会覆盖我原来的起源制造商。

谢谢。

【问题讨论】:

    标签: google-maps-api-3 google-maps-markers


    【解决方案1】:

    如果您可以解决所有问题,则 DirectionsRendererOptions 可以选择隐藏标记。

    https://developers.google.com/maps/documentation/javascript/reference#DirectionsRendererOptions

    【讨论】:

      【解决方案2】:

      您使用setMap() 方法以null 作为参数隐藏/删除标记:

      marker.setMap(null);
      

      查看谷歌文档Remove Marker。请注意,上述方法不会删除标记。它只是从地图中隐藏/删除标记。如果您想再次显示它,只需使用:

      marker.setMap(map);
      

      【讨论】:

        猜你喜欢
        • 2015-05-07
        • 1970-01-01
        • 1970-01-01
        • 2012-04-01
        • 1970-01-01
        • 2011-11-08
        • 1970-01-01
        • 1970-01-01
        • 2012-02-24
        相关资源
        最近更新 更多