Hi All,
Here is one question about U-Turns.
After set the restrictUTurns as "esriNFSBNoBacktrack" (means U-Turn is not allowed), there still could be "Make a U-Turn" in driving directions. How to avoid it ?
Besides, in the example code, there is a "Make a U-turn" from stop 1 to stop 2.
However, there is "Turn left ... " and "Turn left ... " from stop 3 to stop 4.
How to distinguish these two difference scenarios?
You can reproduce this issue by the following code.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://js.arcgis.com/4.29/esri/themes/light/main.css">
<script src="https://js.arcgis.com/4.29/"></script>
<title>U-Turn Directions</title>
<style>
html, body, #viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
require(["esri/Map",
"esri/views/MapView",
"esri/layers/RouteLayer",
"esri/rest/support/Stop",
"esri/widgets/Directions"],
function (Map, MapView, RouteLayer, Stop, Directions) {
(async () =>
{
const apiKey = <YOUR_API_KEY>; // Replace with your api key.
const center = [-73.9056, 42.8041];
const stops = [
new Stop({ geometry: { x: -73.905003, y: 42.803639 }, name: "Stop 1", locationType: "stop", sequence: 1, curbApproach: "right-side-of-vehicle" }),
new Stop({ geometry: { x: -73.905278, y: 42.803887 }, name: "Stop 2", locationType: "stop", sequence: 2, curbApproach: "right-side-of-vehicle" }),
new Stop({ geometry: { x: -73.906477, y: 42.804605 }, name: "Stop 3", locationType: "stop", sequence: 3, curbApproach: "right-side-of-vehicle" }),
new Stop({ geometry: { x: -73.906614, y: 42.804673 }, name: "Stop 4", locationType: "stop", sequence: 4, curbApproach: "right-side-of-vehicle" })
];
const routeLayer = new RouteLayer({ stops });
const map = new Map({
basemap: "streets-vector",
layers: [routeLayer]
});
const view = new MapView({
map: map,
container: "viewDiv",
zoom: 16,
center: center
});
const directionsWidget = new Directions({
apiKey: apiKey,
view: view,
layer: routeLayer
});
view.ui.add(directionsWidget, {
position: "top-right"
});
await Promise.all([view.when(), routeLayer.load(), directionsWidget.when()]);
const restrictUTurns = "no-backtrack"; // U-Turn is not allowed
const routeParameters = { apiKey, restrictUTurns }
const results = await routeLayer.solve(routeParameters);
routeLayer.update(results);
await view.goTo(routeLayer.routeInfo.geometry);
})();
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
The driving directions given by ArcGIS Pro (3.2.1) is different to the ArcGIS Online.
Is there anything I missed for the U-Turns?
Environment
ArcGIS Online
JavaScript API 4.29 (latest)
ArcGIS Pro (3.2.1)
Thanks,
Leo
Solved! Go to Solution.
There is currently no way to affect this behavior with routes solved through ArcGIS Online
There is currently no way to affect this behavior with routes solved through ArcGIS Online
The question lacks context. Are you delivering a small parcel or filling a Natural Gas tank?
If you Can, change the associated Network Position (Source OID and PosAlong) of the first and last stops (in this example).
You will lose four Left Turns (two U-Turns) and be left with a single Right Turn.
If you start the route by heading West on Eastern Parkway, Park the vehicle, and walk across the grass center median, you can visit both stops on that block, continue West, and then take a Right turn on Lakewood Avenue heading North. You could again walk across the grass center median to visit both stops without having any Left Turns across Traffic or U-Turns.
After departure, you could stop by Rosario's Trattoria for a Lasagna or a Pizza.