How to call driving.search circularly to realize the track playback of each path sequentially?

how can paths be played back sequentially? The result of the execution of the following code is that all paths are played back at the same time. What I want to achieve is that the track retrieved by the first seach is played back and then the track of the second path is played back, and so on.

drawTrack(){
            var _this = this;
            _this.map.centerAndZoom(new BMap.Point(113.139612, 27.834782), 15);
            for (let index = 0; index < _this.pointObj.length-1; indexPP) {
                var driving = new BMap.DrivingRoute(_this.map, { 
                    renderOptions: { 
                        map: _this.map, 
                        autoViewport: true
                    },
                    onMarkersSet:function(routes) {
                        if(index != 0) _this.map.removeOverlay(routes[0].marker); //
                        else  _this.addClickHandler(_this.map, _this.openInfor[0], routes[0].marker); // 

                        if(index != _this.pointObj.length-2) _this.map.removeOverlay(routes[1].marker);//
                        else _this.addClickHandler(_this.map, _this.openInfor[1], routes[1].marker); // 
                        
                    },
                    onSearchComplete: function(res) {
                        var pts = res.getPlan(0).getRoute(0).getPath();    //
                        var paths = pts.length;    //
                        var carMk = new BMap.Marker(pts[0]);
                        _this.map.addOverlay(carMk);
                        var i=0;
                        function resetMkPoint(i){
                            carMk.setPosition(pts[i]);
                            if(i < paths){
                                setTimeout(function(){
                                    iPP;
                                    resetMkPoint(i);
                                },100);
                            } else {
                               _this.map.removeOverlay(carMk); 
                            }
                        }
                        setTimeout(function(){
                            resetMkPoint(5);
                        },100)
                    },
                })
                driving.search(_this.pointObj[index], _this.pointObj[index+1])
            }

result: the onSearchComplete function of each path is executed simultaneously.

expect to achieve results: the new annotation goes from the first starting point to the last destination.

May.22,2021

driving.search (start, end, {waypoint:arr}) there are three parameters, start: starting point, end: end point, {waypoint:arr} passing point, and putting the array of passing points into the third parameter, you can draw the path planning according to the specified anchor point

.
Menu