Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

var directionsService = new google.maps.DirectionsService(); var directionsDisplay = new google.maps.DirectionsRenderer();  var startMarker = new google.maps.Marker({ position: start, map: map, icon: 'start.png' }); var stopMarker = new google.maps.Marker({ position: stop, map: map, icon: 'stop.png' });  directionsDisplay.setMap(map);  var request = {  origin: start,   destination: stop,  travelMode: google.maps.DirectionsTravelMode.DRIVING };  directionsService.route(request, function(response, status) {  if (status == google.maps.DirectionsStatus.OK) {   directionsDisplay.setDirections(response);  } }); 

Hi, this script shows route from start point to stop point and i use custom icons, but defaults green A and B also appear. Question is how do i remove default A and B markers so i will see only my custom ones ?

like image 230
frytaz Avatar asked Jul 16 '10 10:07

frytaz


People also ask

How do I remove a default marker from Google Maps?

Just set clickableIcons: false in the options you initialise the Map with. I added an example, you have to zoom enough to see those points. Thank you! These POI's should be turned off by default in the APi.

How do I get rid of blue markers on Google Maps?

If you want to remove the pin from Google Maps, simply right click on it and select "Remove this destination." Poof, it's gone.


1 Answers

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 } ); 
like image 88
tvanfosson Avatar answered Sep 23 '22 02:09

tvanfosson