Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
387 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 } );

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...