Baidu map API map.removeOverlay () can not clearly marker

        var map = new BMap.Map("allmap");
        var start = new BMap.Point(114.02597366,22.54605355);
        var end = new BMap.Point(114.22597366, 22.59605355);
        var driving = new BMap.DrivingRoute(map, { 
            renderOptions: { 
                map: map, 
                autoViewport: true,
                onMarkersSet:function(routes){
        map.removeOverlay(routes[0].marker);//
        map.removeOverlay(routes[1].marker);//
        }
            }
        });
        driving.search(start, end);

result

Why is it useless for me to perform a clear operation here?

Mar.29,2021

var map = new BMap.Map("allmap");
var start = new BMap.Point(114.02597366,22.54605355);
var end = new BMap.Point(114.22597366, 22.59605355);
var driving = new BMap.DrivingRoute(map, { 
    renderOptions: { 
        map: map, 
        autoViewport: true
    },
    onMarkersSet:function(routes) {
        map.removeOverlay(routes[0].marker); //
        map.removeOverlay(routes[1].marker);//
    }
});
driving.search(start, end);

reference http://lbsyun.baidu.com/cms/j.
onMarkersSet is a parameter of DrivingRouteOptions, not a parameter of renderOptions

Menu