I recently started using JavaScript API in attempt to construct a web app. After taking a recent ESRI online course, I thought I had some base knowledge on how to do this.
This geoprocessing service I'm using from our development server is supposed to take an input of a ZipCode and in turn display delivery routes associated with said ZipCode.
I've looked at some sample code on the ArcGIS Javascript API help site and cannot figure out how to execute this with its parameters.
If anyone has any insight or where I can look for documentation on how I can initiliaze this task and make it appear on my WebMap, I'd be forever indebted.
Thanks!
Below is the REST services page for the geoprocessor.
Execution Type: esriExecutionTypeSynchronous
Parameters:
Parameter: ZIP
Data Type: GPString
Display Name ZIP
Description: ZIP code or list of comma, space, or tab delimited 5 digit ZIP codes
Direction: esriGPParameterDirectionInput
Default Value: 38138
Parameter Type: esriGPParameterTypeRequired
Category:
Parameter: Rte_Box
Data Type: GPString
Display Name Rte_Box
Description: R = carrier route, B = PO Box
Direction: esriGPParameterDirectionInput
Default Value: R
Parameter Type: esriGPParameterTypeOptional
Category:
Parameter: Output_Feature_Class
Data Type: GPFeatureRecordSetLayer
Display Name Output_Feature_Class
Description: Geometry and delivery stats for routes that meet search criteria
Direction: esriGPParameterDirectionOutput
Default Value:
Geometry Type: esriGeometryPolyline
HasZ: false
HasM: false
Spatial Reference: 102100 (3857)
Fields:
OBJECTID ( type: esriFieldTypeOID , alias: OBJECTID )
ZIP_CRID ( type: esriFieldTypeString , alias: ZIP_CRID , length: 13 )
ZIP_CODE ( type: esriFieldTypeString , alias: ZIP_CODE , length: 5 )
CRID_ID ( type: esriFieldTypeString , alias: CRID_ID , length: 4 )
CRID_IND ( type: esriFieldTypeString , alias: CRID_IND , length: 1 )
CRID_NBR ( type: esriFieldTypeString , alias: CRID_NBR , length: 3 )
CITY_STATE ( type: esriFieldTypeString , alias: CITY_STATE , length: 32 )
BUS_CNT ( type: esriFieldTypeDouble , alias: BUS_CNT )
TOT_CNT ( type: esriFieldTypeDouble , alias: TOT_CNT )
DROP_CNT ( type: esriFieldTypeDouble , alias: DROP_CNT )
RES_CNT ( type: esriFieldTypeDouble , alias: RES_CNT )
DROPSHIP_KEY ( type: esriFieldTypeString , alias: DROPSHIP_KEY , length: 6 )
FACILITY_NAME ( type: esriFieldTypeString , alias: FACILITY_NAME , length: 35 )
LESS_THAN200_IND ( type: esriFieldTypeString , alias: LESS_THAN200_IND , length: 1 )
FAUX_IND ( type: esriFieldTypeString , alias: FAUX_IND , length: 1 )
LT_200_IND ( type: esriFieldTypeString , alias: LT_200_IND , length: 1 )
DS_KEY ( type: esriFieldTypeString , alias: DS_KEY , length: 7 )
FAC_NAME ( type: esriFieldTypeString , alias: FAC_NAME , length: 35 )
Shape_Length ( type: esriFieldTypeDouble , alias: Shape_Length )
Features: None.
Parameter Type: esriGPParameterTypeRequired
Category:
Best Answer
You need to look at the documentation for the GeoProcessor.
Basically, you will create a new geoprocessor object like this:
gp = new esri.tasks.Geoprocessor("http://YourServer/ArcGIS/rest/services/foo/GPServer/bar");
Then you will need to create a parameter object, with the two required parameters. for this, I'm assuming you will need to take the user's input and put in the zip code, as the RTE_box if required. so your code can be somethinglike this:
You will then call the execute function on the geoprocessor, also passing in the callback function, like this:
In your onResults function, you will get the resulting featureset, which you can then draw on the map as graphics.
There are several samples available, like this one: Service area task