【问题标题】:Removing start and end markers from Google Maps Driving Directions从谷歌地图行车路线中删除开始和结束标记
【发布时间】:2012-04-11 14:30:39
【问题描述】:

我有一张地图,上面有从纽约到洛杉矶的行车路线。

当我输入始发地:纽约,目的地:洛杉矶,加州时效果很好

但我只想使用 lat 和 lng,因为我不想看到 Google 地图在地图上放置的标记。我宁愿只看到从一个城市到另一个城市的折线,没有 GREEN,Not RED 标记。

我尝试改用这个:

new google.maps.LatLng(40.7142, 74.0064);

但它不起作用。我把这一切都放在jsfiddle

如果没有这些标记,您可能无法使用 Google 地图进行行车路线?

【问题讨论】:

标签: jquery google-maps


【解决方案1】:

设置以下属性:

directionsDisplay.suppressMarkers = true;

就在这一行之后

directionsDisplay = new google.maps.DirectionsRenderer({polylineOptions: polylineOptionsActual});

Docs for DirectionsRenderer options are here

【讨论】:

    【解决方案2】:

    无法让您的 jsfiddle 工作,我不知道是否必须使用标记来创建您正在谈论的方向。也许是,也许不是,我对 Google Maps API 的了解还不够多。

    但是,你为什么不按你说的那样使用标记,而只是给它们一个透明的图像呢?

    var markerIcon = new google.maps.MarkerImage("img/blank.gif",new google.maps.Size(1, 1),new google.maps.Point(0, 0),new google.maps.Point(0, 0));
    new google.maps.Marker({ map: map, position: position, icon: markerIcon });
    

    MarkerImage 将标准 Google 地图标记图像(红色大头针)替换为指定图像。

    【讨论】:

      猜你喜欢
      • 2012-05-17
      • 1970-01-01
      • 2015-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-10
      • 2015-04-09
      相关资源
      最近更新 更多