I am trying to use a feature layer from ArcGIS Online to be an input facility in my closest facility parameter. I just recently started using ArcGIS JavaScript API and I saw someone's example in this forum which looks similar to this:
The code runs but returns no results:
Solved! Go to Solution.
In your codepen you are mixing 3.x and 4.x code; that won't work. Here's a slightly modified version of your code that gets and sets the facilities before you start trying to call the solver:
https://codepen.io/john-grayson/pen/oNZgPYX
Hi @JohnPaulAlbana, can you post a link to an app that reproduces this issue? On something like Codepen would be great. You can omit the apiKey if you are using one. Then I can investigate further.
Hi @Noah-Sager , thanks for coming by, here is the codepen link:
The first error you see when loading the app is: Uncaught (in promise) ReferenceError: facilities is not defined
So we need to get the locations of the features into a facilities variable. There is some good doc to go through here: https://developers.arcgis.com/documentation/mapping-apis-and-services/routing/closest-facility-routi...
I can take a closer look next week as well.
In your codepen you are mixing 3.x and 4.x code; that won't work. Here's a slightly modified version of your code that gets and sets the facilities before you start trying to call the solver:
https://codepen.io/john-grayson/pen/oNZgPYX