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 markers A and B onto the map ( calculating directions from point A to point B ). I do not have control over these markers, so I cannot remove them in the normal way. So how can I remove these markers (I have custom markers on the map instead)?
问问题
28201 次
2 回答
38
suppressMarkers
创建对象时将选项设置为 true DirectionsRenderer
,然后标记将不会显示。您还可以更改标记的样式或图标。有关您可以设置的其他属性,请参阅DirectionsRendererOptions的 API 规范。
...
directionsDisplay = new google.maps.DirectionsRenderer({suppressMarkers: true});
...
编辑:自从我大约 6 年前的原始答案以来,API 似乎发生了一些变化,所以@joni-jones 的答案现在是正确的方法。我调整了上面的示例以反映这一点。
于 2010-05-31T22:03:02.700 回答
33
我有一个类似的问题。以前的解决方案对我没有帮助。但我试过这个:
var directionDisplay = new google.maps.DirectionsRenderer({suppressMarkers: true});这是工作。
于 2013-01-12T22:09:15.063 回答