Removing Directions markers from the Google Maps API V3

后端 未结 2 1078
独厮守ぢ
独厮守ぢ 2020-12-28 14:31

To remove a normal marker from a map, I understand you simply call marker.setMap(null), but when implementing the Google Maps directions services, it automatically adds mark

相关标签:
2条回答
  • 2020-12-28 15:17

    Set the suppressMarkers option to true when creating your DirectionsRenderer object and then the markers won't show up. You could also change the style or icon of the markers. See the API spec for DirectionsRendererOptions for other properties you can set.

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

    EDIT: It looks like the API changed a little bit since my original answer almost 6 years ago, so the answer from @joni-jones is now the correct way. I tweaked my example above to reflect that.

    0 讨论(0)
  • 2020-12-28 15:29

    I had a similar problem. The previous solution did not help me. But I tried this:

    var directionsDisplay = new google.maps.DirectionsRenderer({suppressMarkers: true});
    And it's work.

    0 讨论(0)
提交回复
热议问题