Select to view content in your preferred language

Facility Input for Closest Facility Analysis

1192
2
Jump to solution
12-14-2013 06:40 AM
WesAskew
Deactivated User
I am new to ArcGIS for JavaScript and am having trouble performing a closest facility analysis.  I have a feature layer from a REST feature service that I would like to be the facility layer input.  The sample that my code is based on is located here:  https://developers.arcgis.com/en/javascript/jssamples/routetask_closest_facility.html.  This sample uses manually input lat/long info to draw graphics, which is then converted to a feature set.   What is the best way that I should go about obtaining a  feature set from my feature layer?  I have tried multiple methods but all have failed.  Thanks in advance.
0 Kudos
1 Solution

Accepted Solutions
BjornSvensson
Esri Regular Contributor
I have a feature layer from a REST feature service that I would like to be the facility layer input.  ...What is the best way that I should go about obtaining a  feature set from my feature layer?


The input can be either a FeatureSet OR a DataLayer, so you can point it straight to your feature service.

See the API Reference at https://developers.arcgis.com/en/javascript/jsapi/closestfacilityparameters.html#facilities for something like:
//Requires ArcGIS Server 10.1 or greater params.facilities = new esri.tasks.DataFile({   url: "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/3/query?where=1%3D1&returnGeometry=true&outFields=*&f=json" });

View solution in original post

0 Kudos
2 Replies
BjornSvensson
Esri Regular Contributor
I have a feature layer from a REST feature service that I would like to be the facility layer input.  ...What is the best way that I should go about obtaining a  feature set from my feature layer?


The input can be either a FeatureSet OR a DataLayer, so you can point it straight to your feature service.

See the API Reference at https://developers.arcgis.com/en/javascript/jsapi/closestfacilityparameters.html#facilities for something like:
//Requires ArcGIS Server 10.1 or greater params.facilities = new esri.tasks.DataFile({   url: "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/3/query?where=1%3D1&returnGeometry=true&outFields=*&f=json" });
0 Kudos
JohnPapageorgiou
Regular Contributor

Hi,

I'm having the same problem as Wesley, where exactly does the substitution happen?  I tried it in several places without success.  Do I need to use a map service or a feature service?  I'm kind of at a loss of what a feature set is.  Main point is I don't want to write a list of all my facilities with their coordinates in the code, I would like to draw that from a data set such as a feature service.

thanks,

John

0 Kudos