<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Routing with polygon barriers not working Javascript API 4.24 in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/routing-with-polygon-barriers-not-working/m-p/1226430#M79154</link>
    <description>&lt;P&gt;I have routing set up in my web app and working, except when I try to add a rest feature service for polygonBarriers property of RouteParameters, it fails.&amp;nbsp; This is how I'm defining the polygonBarriers in the RouteParameters:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;const routeParams = new RouteParameters({&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;stops: new FeatureSet({&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;features: view.graphics.toArray()&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;returnPolygonBarriers: true,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;polygonBarriers: {&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;"url" : "&lt;A href="https://maps.gilbertaz.gov/arcgis/rest/services/GilbertDays2022Closure/FeatureServer/1/query?where=1%3D1&amp;amp;returnGeometry=true&amp;amp;f=json" target="_blank"&gt;https://maps.gilbertaz.gov/arcgis/rest/services/GilbertDays2022Closure/FeatureServer/1/query?where=1%3D1&amp;amp;returnGeometry=true&amp;amp;f=json&lt;/A&gt;"&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;});&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The error I get is below.&amp;nbsp; I am pretty sure I am doing this the way the javascript API Reference show it, however I am not getting this to work.&amp;nbsp; I get this error in the console:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;RouteParameters.js:5 Uncaught (in promise) TypeError: n.toJSON is not a function&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at r (RouteParameters.js:5:156)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at f.writePolygonBarrier (RouteParameters.js:8:186)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at q ((index):263:421)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at a.write ((index):266:327)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at f.write ((index):254:370)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at f.toJSON ((index):254:420)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at e.routeParametersToQueryParameters (utils.js:5:115)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at Module.&amp;lt;anonymous&amp;gt; (route.js:6:98)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at Generator.next (&amp;lt;anonymous&amp;gt;)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at d ((index):35:26)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for any assistance provided.&amp;nbsp; It may just be something minor that I'm overlooking, I've never worked with routing before...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Oct 2022 21:49:02 GMT</pubDate>
    <dc:creator>JS_GilbertAZ</dc:creator>
    <dc:date>2022-10-27T21:49:02Z</dc:date>
    <item>
      <title>Routing with polygon barriers not working Javascript API 4.24</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/routing-with-polygon-barriers-not-working/m-p/1226430#M79154</link>
      <description>&lt;P&gt;I have routing set up in my web app and working, except when I try to add a rest feature service for polygonBarriers property of RouteParameters, it fails.&amp;nbsp; This is how I'm defining the polygonBarriers in the RouteParameters:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;const routeParams = new RouteParameters({&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;stops: new FeatureSet({&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;features: view.graphics.toArray()&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;returnPolygonBarriers: true,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;polygonBarriers: {&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;"url" : "&lt;A href="https://maps.gilbertaz.gov/arcgis/rest/services/GilbertDays2022Closure/FeatureServer/1/query?where=1%3D1&amp;amp;returnGeometry=true&amp;amp;f=json" target="_blank"&gt;https://maps.gilbertaz.gov/arcgis/rest/services/GilbertDays2022Closure/FeatureServer/1/query?where=1%3D1&amp;amp;returnGeometry=true&amp;amp;f=json&lt;/A&gt;"&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;});&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The error I get is below.&amp;nbsp; I am pretty sure I am doing this the way the javascript API Reference show it, however I am not getting this to work.&amp;nbsp; I get this error in the console:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;RouteParameters.js:5 Uncaught (in promise) TypeError: n.toJSON is not a function&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at r (RouteParameters.js:5:156)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at f.writePolygonBarrier (RouteParameters.js:8:186)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at q ((index):263:421)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at a.write ((index):266:327)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at f.write ((index):254:370)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at f.toJSON ((index):254:420)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at e.routeParametersToQueryParameters (utils.js:5:115)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at Module.&amp;lt;anonymous&amp;gt; (route.js:6:98)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at Generator.next (&amp;lt;anonymous&amp;gt;)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;at d ((index):35:26)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for any assistance provided.&amp;nbsp; It may just be something minor that I'm overlooking, I've never worked with routing before...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2022 21:49:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/routing-with-polygon-barriers-not-working/m-p/1226430#M79154</guid>
      <dc:creator>JS_GilbertAZ</dc:creator>
      <dc:date>2022-10-27T21:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: Routing with polygon barriers not working Javascript API 4.24</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/routing-with-polygon-barriers-not-working/m-p/1226487#M79157</link>
      <description>&lt;P&gt;I think stop is not understanding the parameters in new RouteParameters, I am also learning route.&amp;nbsp; Bellow is the code, which I have taken from ESRI and applied my API key.&amp;nbsp; How I can generate error, which you are getting.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /&amp;gt;
    &amp;lt;title&amp;gt;Route | Sample | ArcGIS API for JavaScript 4.24&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }

      #paneDiv {
        position: absolute;
        top: 10px;
        left: 62px;
        padding: 0 12px 0 12px;
        background-color: rgba(0, 0, 0, 0.5);
        color: white;
      }
    &amp;lt;/style&amp;gt;

    &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.24/esri/themes/light/main.css" /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.24/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script&amp;gt;
      require([
        "esri/Map",
        "esri/views/MapView",
        "esri/Graphic",
        "esri/layers/GraphicsLayer",
        "esri/rest/route",
        "esri/rest/support/RouteParameters",
        "esri/rest/support/FeatureSet"
      ], function(Map, MapView, Graphic, GraphicsLayer, route, RouteParameters, FeatureSet) {

        // Point the URL to a valid routing service
        const routeUrl = "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World";

        // The stops and route result will be stored in this layer
        const routeLayer = new GraphicsLayer();

        // Setup the route parameters
        const routeParams = new RouteParameters({
          // An authorization string used to access the routing service
          apiKey: "MY-API-KEY",
// provide the array, to check
          stops: new FeatureSet(),
          outSpatialReference: {
            // autocasts as new SpatialReference()
            wkid: 3857
          }
        });

        // Define the symbology used to display the stops
        const stopSymbol = {
          type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
          style: "cross",
          size: 15,
          outline: {
            // autocasts as new SimpleLineSymbol()
            width: 4
          }
        };

        // Define the symbology used to display the route
        const routeSymbol = {
          type: "simple-line", // autocasts as SimpleLineSymbol()
          color: [0, 0, 255, 0.5],
          width: 5
        };

        const map = new Map({
          basemap: "streets-navigation-vector",
          layers: [routeLayer] // Add the route layer to the map
        });

        const view = new MapView({
          container: "viewDiv", // Reference to the scene div created in step 5
          map: map, // Reference to the map object created before the scene
          center: [-117.195, 34.057],
          zoom: 13
        });

        // Adds a graphic when the user clicks the map. If 2 or more points exist, route is solved.
        view.on("click", addStop);

        function addStop(event) {
          // Add a point at the location of the map click
          const stop = new Graphic({
            geometry: event.mapPoint,
            symbol: stopSymbol
          });
          routeLayer.add(stop);

          // Execute the route if 2 or more stops are input
          routeParams.stops.features.push(stop);
          if (routeParams.stops.features.length &amp;gt;= 2) {
            route.solve(routeUrl, routeParams).then(showRoute);
          }
        }
        // Adds the solved route to the map as a graphic
        function showRoute(data) {
          const routeResult = data.routeResults[0].route;
          routeResult.symbol = routeSymbol;
          routeLayer.add(routeResult);
        }
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;div id="paneDiv" class="esri-widget"&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;p&amp;gt;
          Click on the map to add stops to the route. The route from the last stop to the newly added stop is
          calculated. If a stop is not reachable, then the last valid point is set as the starting point.
        &amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 02:38:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/routing-with-polygon-barriers-not-working/m-p/1226487#M79157</guid>
      <dc:creator>JayakumarPD</dc:creator>
      <dc:date>2022-10-28T02:38:38Z</dc:date>
    </item>
  </channel>
</rss>

