views:

482

answers:

2

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)?

+2  A: 

Set the supressMarkers property to true on your DirectionsRenderer object and then the markers won't show up. You could also use the markerOptions property if you wanted to change the style or icon of the markers. See the API spec for DirectionsRendererOptions for other properties you can set.

So wherever you initialize your DirectionsRenderer object, immediately set the supressMarkers property. For example...

   ... 
   directionsDisplay = new google.maps.DirectionsRenderer();
   directionsDisplay.suppressMarkers = true;
   ...
Mark
That makes the trick ! Thanks
Natim
Yes, this is exactly what I was looking for. Thanks!
anonymous
A: 

hi, I've suppressMarkers and i need to put my own custom marker one at the start (image1) and onde at the end (image2), for this i simple create a marker1 with options and marker2 with another options?

thanks

TiagoMartins