【问题标题】:How to change default markers in google map api3 direction service? [duplicate]如何更改谷歌地图 api3 方向服务中的默认标记? [复制]
【发布时间】:2017-07-22 13:58:12
【问题描述】:

我想更改默认标记图标 A、B 和航路点图标(参考图片附在下面)。

这个标记也可以拖动。如果我拖动那些标记,它应该放置在除大海、河流等之外的道路上。我上周尝试了很多方法。上周我没有找到任何解决方案。

【问题讨论】:

  • 添加标记的当前代码是什么
  • @geocodezip,在您的示例中,如果我拖动标记,航点图标的位置不正确。

标签: javascript html google-maps-api-3 google-geocoder


【解决方案1】:

你可以用这个删除标记:

directionsDisplay.setOptions( { suppressMarkers: true } );

因为你有方向参数“destination”你知道你要去哪里,所以你可以自己添加另一个:

var latlngDestination = new google.maps.LatLng(???,???) ;
var markerDestination = new google.maps.Marker({
            map: map,
            position: latlngDestination,
            draggable: true,
            icon: 'http://www.google.com/mapfiles/markerA.png'
    });

    directionsService.route({
        origin: ???,
        destination: latlngDestination ,
        travelMode: 'DRIVING'
    }

对于捕捉部分,您在这里有相同的问题和解决方案:Snap to nearest street

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-15
    • 1970-01-01
    • 2014-09-16
    • 1970-01-01
    • 2020-01-09
    • 1970-01-01
    相关资源
    最近更新 更多