如何删除谷歌地图路线方向上的默认A B标记 [英] How to remove default A B markers on google maps route direction

查看:601
本文介绍了如何删除谷歌地图路线方向上的默认A B标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这个脚本显示从起点到终点的路线,我使用自定义图标,但默认为绿色A和B也出现。
问题是我如何去除默认的A和B标记,所以我只会看到我自定义的那些标记?

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 ?

推荐答案

试试使用 suppressMarkers 选项在DirectionsRenderer上防止显示路线上的标记。这应该使您已经直接添加到地图的标记留下,但不会显示与路线相关的标记。

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

这篇关于如何删除谷歌地图路线方向上的默认A B标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆