Issues with avoidPoints and ferry using Leaflet Routing Machine

Hello everyone,

I am developing an app about Venice using Routing.

The problem is that I would like to let tourists pass through the accessible penti provided with ramp and avoid the inaccessible ones.

The app is based on Leaflet and routing machine with leaflet.openrouting service extension,

below I paste the call to your service:

function getRoute(destination) {
  var userType = $(“#userType”).val();
  var startPoint = $(“#userCurrentPosition”).val().split(“,”);
  var endPoint = destination.split(“,”);
  const apiKey = '5b3ce3597851110001cf6248d9932d42de9e4a52a4ba0dba55a0ddf1';

  const osrRouter = new L.Routing.OpenRouteService(apiKey, {
      “timeout": 30 * 1000,
      “format": ‘json’,
      “host": ‘https://api.openrouteservice.org’,
      “service": ‘directions’,
      “api_version": ‘v2’,
      “profile": ‘foot-walking’,
      “preference": ‘fastest’,
      “routingQueryParams": {
          “language": ‘en’,
          “maneuvers": true,
          “options": {
            “avoid_polygons": {
              “type": ‘multiPolygon’,
              “coordinates": [avoidPoints] // Use the points to avoid loaded from the JSON
          }
              // “avoid_features”: [“steps”]
              
          }
      }
  });

Within the variable “avoidPoints” I have the polygons of the bridges to be avoided to avoid.
Graphically, the line still crosses the bridge it is supposed to avoid.

also i have problems with navigation, where by inserting “profile”: “ferry”
thank you

Hi @Marco_Miiretto,

please make sure you understand what options you can actually pass in your query by reading our API Documentation.

  • make sure your avoidPoints are formatted as valid GeoJSON, either a Polygon or MultiPolygon object
  • we don’t have a ferry profile. You could use our foot-walking profile which can use ferries if they are not avoided.

Best regards

1 Like