AnsweredAssumed Answered

How to implement restriction on routing?

Question asked by leo.deng.transfinder on Jun 15, 2017
Latest reply on Jun 15, 2017 by leo.deng.transfinder

All, 

   I'm using esri javascript api 3.20.

   I want to implement an ONE-WAY restriction for route analysis.

  The network server (NAServer) has an attribute "Driving a Passenger Car". (TomTom North America data)

  In arcmap, the results are as expected.

But when using esri js api, the results was

 

How to apply the one-way restriction?

 

var layer = new GraphicsLayer({id: 'route'});
map.addLayer(layer);

var features = [];
var p1 = new Graphic(new Point(-73.936131, 42.818060), stopSymbol);
var p2 = new Graphic(new Point(-73.936946, 42.819637), stopSymbol);
features.push(p1);
features.push(p2);

layer.add(p1);
layer.add(p2);

var featureSet = new FeatureSet();
featureSet.features = features;
parameters.stops = featureSet;

parameters.outSpatialReference = {wkid: 3857};
parameters.returnStops = true;
parameters.returnDirections = true;
parameters.directionsTimeAttributes = "Minutes";
parameters.outputLines = NATypes.OutputLine.TRUE_SHAPE;
parameters.doNotLocateOnRestrictedElements = false;
parameters.attributeParameterValues = [{
     "attributeName": "Driving a Passenger Car",
     "parameterName": "Restriction Usage",
     "value": "Prohibited"
}];
parameters.restrictionAttributes = ['Driving a Passenger Car'];

task.solve(parameters).then(function(results){

     var routeResults = results.routeResults[0],
          route = routeResults.route;
    
     route.setSymbol(routeSymbol);
    
     layer.add(route);  // the route without restriction
    
}.bind(this), function(error){
     console.log(error);
}.bind(this));

Outcomes