<?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 Re: Routing with added/scaled cost barriers in custom widget in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/routing-with-added-scaled-cost-barriers-in-custom/m-p/1351809#M9479</link>
    <description>&lt;P&gt;Thanks, I'll do that. Do you know if this is more appropriate for the JavaScript Maps SDK or the ArcGIS REST JS community? On one hand I'm using the rest APIs (like&amp;nbsp;'esri/rest/support/RouteParameters') On the other hand I'm not using a direct request to a url, but a JS function.&amp;nbsp; Thanks again&lt;/P&gt;</description>
    <pubDate>Tue, 21 Nov 2023 03:35:04 GMT</pubDate>
    <dc:creator>Yik-ChingTsui</dc:creator>
    <dc:date>2023-11-21T03:35:04Z</dc:date>
    <item>
      <title>Routing with added/scaled cost barriers in custom widget</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/routing-with-added-scaled-cost-barriers-in-custom/m-p/1351318#M9453</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;I'm trying to get routing working using the JS REST API. It will be used in a custom widget in experience builder. I got point barriers working with PointBarrier, but I need it to be added cost and it ignores everything I try. The ultimate goal is actually to use polyline barriers with scaled cost, but point barriers are simpler and neither worked.&lt;/P&gt;&lt;P&gt;Here is the code I have:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// variables from elsewhere
const vars = {
    // start and end point
    start, end,
    // JimuMapView
    jmv
}

const url = 'https://my-portal.com/server/rest/services/NetworkAnalysis/NAServer/Route'

const stops = new Collection([
  new Stop({
    geometry: vars.start
  }),
  new Stop({
    geometry: vars.end
  }),
])

const point = new Point({
  x: 114.168562,
  y: 22.322603
});

const start = [
  114.16853662192821, 22.323295447135724
]
const end = [
  114.16890644904946, 22.32143923097987
]
const path = [start, end]
const polyline = new Polyline({
  paths: [path]
})

const params1 = new RouteParameters({
  stops,
  pointBarriers: new Collection([
    new PointBarrier({
      geometry: point
    })
  ]),
//   pointBarriers: new Collection([
//     new NetworkFeatureSet({
//       features: [
//         new Graphic({
//           geometry: point,
//         })
//       ]
//     })
//   ]),
//   polylineBarriers: new Collection([
//     new NetworkFeatureSet({
//       features: [
//         new Graphic({
//           geometry: polyline,
//         })
//       ],
//     })
//  ])
})

route.solve(url, params1).then(r =&amp;gt; {
  const res = r.routeResults[0].route
  console.log('params1')
  console.log(r)

  const layer = new FeatureLayer({
    title: 'Route',
    source: [res],
    objectIdField: 'ObjectID',
    fields: [
      {
        name: 'ObjectID',
        type: 'oid'
      }
    ],
    renderer: {
      // &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/69004"&gt;@ts&lt;/a&gt;-ignore
      type: 'simple',
      symbol: {
        type: 'simple-line',
        color: 'green',
        width: '2px'
      },
    }
  })

  vars.jmv.view.map.add(layer)
})&lt;/LI-CODE&gt;&lt;P&gt;That code has a working point barrier, but if the commented-out point barrier is used instead, it ignores the point barrier.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;I use NetworkFeatureSet instead of PointBarrier as the former &lt;SPAN&gt;can carry attribute data, which should allow me to add cost to the barriers. (Or is there an alternative way to specify the cost for barrier?). I didn't specify attributes yet for the above code, because the simpler case of a completely restricted barrier isn't even working.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The second commented out code is the polyline barrier attempt using&amp;nbsp;NetworkFeatureSet, which doesn't work at all. The RouteSolveResult has null for the polylineBarrier and pointBarrier when using&amp;nbsp;NetworkFeatureSet, so it outright ignores it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I don't need to use&amp;nbsp;NetworkFeatureSet, I'll accept anything that can make routing work with added/scaled costs barriers. Thank you very much. Please let me know if I can provide additional context&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 03:53:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/routing-with-added-scaled-cost-barriers-in-custom/m-p/1351318#M9453</guid>
      <dc:creator>Yik-ChingTsui</dc:creator>
      <dc:date>2023-11-20T03:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: Routing with added/scaled cost barriers in custom widget</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/routing-with-added-scaled-cost-barriers-in-custom/m-p/1351440#M9460</link>
      <description>&lt;P&gt;I have not used this part of the Javascript API. You may want to re-post your question over on the API question boards. You will likely find some more experienced developers over there.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 14:07:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/routing-with-added-scaled-cost-barriers-in-custom/m-p/1351440#M9460</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2023-11-20T14:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Routing with added/scaled cost barriers in custom widget</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/routing-with-added-scaled-cost-barriers-in-custom/m-p/1351809#M9479</link>
      <description>&lt;P&gt;Thanks, I'll do that. Do you know if this is more appropriate for the JavaScript Maps SDK or the ArcGIS REST JS community? On one hand I'm using the rest APIs (like&amp;nbsp;'esri/rest/support/RouteParameters') On the other hand I'm not using a direct request to a url, but a JS function.&amp;nbsp; Thanks again&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 03:35:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/routing-with-added-scaled-cost-barriers-in-custom/m-p/1351809#M9479</guid>
      <dc:creator>Yik-ChingTsui</dc:creator>
      <dc:date>2023-11-21T03:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Routing with added/scaled cost barriers in custom widget</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/routing-with-added-scaled-cost-barriers-in-custom/m-p/1351908#M9482</link>
      <description>&lt;P&gt;I would go to the JavaScript Maps SDK.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 13:08:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/routing-with-added-scaled-cost-barriers-in-custom/m-p/1351908#M9482</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2023-11-21T13:08:10Z</dc:date>
    </item>
  </channel>
</rss>

