Task: the user needs to select point A and B in order to build a route. But at the same time, to add a transit point, so that you can flexibly change the middle of the route. Now I have a code similar to the example from the documentation that uses control.RoutePanel.

And I would like the transit point to appear after constructing the route, as in this example from the documentation .

I tried to add code like this, but it doesn't work:

this.routePanelControl.routePanel .getRouteAsync() .then(function(multiRoute) { multiRoute.events.add("update", function() { multiRoute.options.set({viaIndexes: [2]}) } }); 

It seems that I can not add this point after the route has already been built without it.

Thank you in advance!

    1 answer 1

    At the moment, control.RoutePanel does not support the addition of intermediate points. You need to write your own control, which would support it.

    An example of where to start when writing your own control can be found here: https://tech.yandex.ru/maps/jsbox/2.1/custom_control

    • Thanks for the answer! And there is no possibility to implement such functionality without control.RoutePanel, but only by means of multiRouter? That it was like in this example , but even the first point would indicate the user? Well, the transit point was added. I actually came to control.RoutePanel, because I could not do it without him. - Alexey Chernov
    • Of course, you can do this without control. RoutePanel , but only by means of multiRouter jsfiddle.net/06edobkz - se0ga
    • Thank you very much for showing an example! I had two questions now: 1) It was not possible to limit the number of waypoint to two (only points A and B). I tried for this the code from the example in the documentation, but the usual Route. 2) If you build a route from two points, then the multiRoute.getActiveRoute () method does not work. For some reason it only works when the third WayPoint appears. multiRoute.getRoutes (). getLength () indicates 0, when two points. Forked your example Thank you for your help! - Alexey Chernov
    • You have chosen the wrong event, the update event is more appropriate in this case jsfiddle.net/wbvtdp0L - se0ga
    • Thank! And on the second question, why getRoutes (). GetLength () returns 0 in my example? - Alexey Chernov