How to remove default A B markers on google maps route direction

后端 未结 3 1679
孤城傲影
孤城傲影 2020-12-13 02:33
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();

var startMarker = new google.maps.Marker(         


        
相关标签:
3条回答
  • 2020-12-13 02:37
    map = new google.maps.Map(document.getElementById("mapCanvas"), mapOptions);
    directionsRenderer.setMap(map); 
    directionsRenderer.setOptions( { suppressMarkers: true } );
    
    0 讨论(0)
  • 2020-12-13 02:45
    directionsDisplay.setOptions({
    polylineOptions: {
                strokeWeight: 4,
                strokeOpacity: 1,
                strokeColor:  'red' 
            }
    });
    
    0 讨论(0)
  • 2020-12-13 02:54

    Try using the suppressMarkers option on the DirectionsRenderer to prevent the markers on the route from being displayed. This should leave the markers that you have added directly to the map in place but not show those associated with the route.

    directionsDisplay.setMap(map);
    directionsDisplay.setOptions( { suppressMarkers: true } );
    
    0 讨论(0)
提交回复
热议问题