google-maps-api-3 - 在 google maps api v3 中隐藏方向服务中的标记

标签 google-maps-api-3

我正在使用这项服务https://developers.google.com/maps/documentation/javascript/directions在两个标记之间创建一条路线。

问题是,当我运行创建路径的函数时,当我创建具有不同样式的标记时,他默认从谷歌地图(开头和结尾)输入两个标记。

结果:在每个点上都有我的标记和标记的默认谷歌地图。

如何隐藏谷歌创建的标记?

我正在使用的代码是:

function makePathToMarker(position1, position2) {
    var request = {
        origin: new google.maps.LatLng(myLocation.split(",")[0],myLocation.split(",")[1]),
        destination: new google.maps.LatLng(position1, position2),
        travelMode: google.maps.DirectionsTravelMode.DRIVING
    };

    var directionsService = new google.maps.DirectionsService();

    directionsService.route(request, function(response, status) {
        if (status == google.maps.DirectionsStatus.OK) {
            directionsDisplay.setDirections(response);
        }
    });
}

最佳答案

实例化 DirectionsRenderer 时,将 suppressMarkers 设置为 true。

  directionsDisplay = new google.maps.DirectionsRenderer(
  {
      suppressMarkers: true
  });

这是reference

关于google-maps-api-3 - 在 google maps api v3 中隐藏方向服务中的标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11509917/

相关文章:

java - 在多个谷歌地图标记之间绘制所有可能的折线?

javascript - Google map Circle 对象自定义 css

javascript - 如何根据从下拉菜单中选择的城市显示 Google map

javascript - 从 php 中按谷歌地图 api 中的城市名称自动填充州和国家/地区

javascript - 谷歌地图标记图标作为变量

google-maps - Google Geocoding API 返回错误的地址,但 Google map 显示正确的位置

javascript - 如何管理和处理谷歌地图标记

javascript - 谷歌地图 API v3 - "Infowindow not defined"错误

google-maps - JavaScript 压缩 |谷歌地图

google-maps - 在 Google Maps API v3 中获取折线的边界