D
D
Dima Pautov2021-11-30 12:49:01
Yandex maps
Dima Pautov, 2021-11-30 12:49:01

How to determine that the yandex map could not build a route with the selected routingMode?

Good afternoon! I build routes in yandex maps indicating the type of route.

const multiRoute = new ymaps.multiRouter.MultiRoute({
    referencePoints: [
      userCoords,
      ...routesCoords
    ]
  }, {
    boundsAutoApply: true,
    wayPointVisible: false,
    routeActiveStrokeColor: '#E30611',
    routeStrokeWidth: 2,
    routeStrokeStyle: '1 2'
  });

  multiRoute.model.setParams({
    routingMode: value // Одно из стандартных значений, которое может принимать карта
  }, true);

  multiRoute.model.events
    .add('requestsuccess', () => {
      map.geoObjects.add(multiRoute);
    })
    .add('requestfail', () => {
            
    });

Everything works perfectly!

The trouble is that at the specified coordinates, the map cannot always build a route.
routingMode = 'auto'always works, but the rest cannot build a route.
How to understand that the map could not build a route? requestfailis not called at this point. Always works only requestsuccess.

I tried to requestsuccessaccept event, but there I did not find any information that the route could not be built. Climbed to the dock, also did not find anything.

If you go to the Yandex maps themselves and enter my addresses, when choosing the route mode, if the map cannot build a route, then it will report this. Help me understand how to calculate this moment?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dima Pautov, 2021-11-30
@bootd

I understood how, you need to do the following
https://yandex.ru/dev/maps/jsapi/doc/2.1/dg/concept...
Just get the active route on a successful request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question