Select to view content in your preferred language

how to give parameters to geoprocessing results as map service

2501
5
Jump to solution
01-16-2014 10:58 AM
MaxDemars
Deactivated User
Hi,

I have published a geoprocess in ArcGIS Server and checked the option to see the result in a map service. I have now a new map service that output the results correctly on the map like this:

var outputBuffer = new esri.layers.ArcGISDynamicMapServiceLayer("http://localhost:6080/arcgis/rest/services/buffer/MapServer",{     opacity: 0.75 }); map.addLayer(outputBuffer);


Now, I would like to know how (if its possible) to define parameters like Query or to give data selection or distance parameters as input. Is it possible to do it simply by adding properties in the layer definition or do I have to use the geoprocessing service instead (not the map service of the geoprocess)?

Thank you,
0 Kudos
1 Solution

Accepted Solutions
RobertoPepato
Deactivated User
Thank you for your help pepatops!

I am not sure to understand well how it works. I tried like this without success:

         var bufferPoly = new esri.tasks.QueryTask("http://localhost:6080/arcgis/rest/services/buffer/MapServer");          var query = new esri.tasks.Query();          query.where = "1=1";          query.returnGeometry = true;          bufferPoly.execute(query);                   bufferPoly.on("complete", function(result){           console.log(result)           map.addLayer(result);          });


I am using the query "1=1" just to test. It should returns all features. There is no error message in the server or console log but the buffers are not rendered on the map. Do I have to define the result layer styles?


You're own your way to go, but you should specify to the query task which layer must have be filtered, by using the layer index on the map service.

So, instead of:

var bufferPoly = new esri.tasks.QueryTask("http://localhost:6080/arcgis/rest/services/buffer/MapServer");


You should have:

var bufferPoly = new esri.tasks.QueryTask("http://localhost:6080/arcgis/rest/services/buffer/MapServer/0");


or 1, or 2, or whatever is the index of the layer being filtered.

Regards.

Roberto Pepato

View solution in original post

0 Kudos
5 Replies
RobertoPepato
Deactivated User
You can use a Query task to filter a layer based on your parameters.

See the following links and let me know if that helps:

https://developers.arcgis.com/en/javascript/jssamples/fl_paging.html
https://developers.arcgis.com/en/javascript/jsapi/querytask-amd.html
0 Kudos
MaxDemars
Deactivated User
Thank you for your help pepatops!

I am not sure to understand well how it works. I tried like this without success:

         var bufferPoly = new esri.tasks.QueryTask("http://localhost:6080/arcgis/rest/services/buffer/MapServer");
         var query = new esri.tasks.Query();
         query.where = "1=1";
         query.returnGeometry = true;
         bufferPoly.execute(query);
        
         bufferPoly.on("complete", function(result){
          console.log(result)
          map.addLayer(result);
         });


I am using the query "1=1" just to test. It should returns all features. There is no error message in the server or console log but the buffers are not rendered on the map. Do I have to define the result layer styles?
0 Kudos
RobertoPepato
Deactivated User
Thank you for your help pepatops!

I am not sure to understand well how it works. I tried like this without success:

         var bufferPoly = new esri.tasks.QueryTask("http://localhost:6080/arcgis/rest/services/buffer/MapServer");          var query = new esri.tasks.Query();          query.where = "1=1";          query.returnGeometry = true;          bufferPoly.execute(query);                   bufferPoly.on("complete", function(result){           console.log(result)           map.addLayer(result);          });


I am using the query "1=1" just to test. It should returns all features. There is no error message in the server or console log but the buffers are not rendered on the map. Do I have to define the result layer styles?


You're own your way to go, but you should specify to the query task which layer must have be filtered, by using the layer index on the map service.

So, instead of:

var bufferPoly = new esri.tasks.QueryTask("http://localhost:6080/arcgis/rest/services/buffer/MapServer");


You should have:

var bufferPoly = new esri.tasks.QueryTask("http://localhost:6080/arcgis/rest/services/buffer/MapServer/0");


or 1, or 2, or whatever is the index of the layer being filtered.

Regards.

Roberto Pepato
0 Kudos
MaxDemars
Deactivated User
You're own your way to go, but you should specify to the query task which layer must have be filtered, by using the layer index on the map service.

So, instead of:

var bufferPoly = new esri.tasks.QueryTask("http://localhost:6080/arcgis/rest/services/buffer/MapServer");


You should have:

var bufferPoly = new esri.tasks.QueryTask("http://localhost:6080/arcgis/rest/services/buffer/MapServer/0");


or 1, or 2, or whatever is the index of the layer being filtered.

Regards.

Roberto Pepato



Thank you, thats do it! I can filter the result by a field and map it. My last question is, is it possible to set the input features, for instance, apply the geoprocessing to a subset of selected features.

Or is it possible to change geoprocessing parameters (like the buffer distance) the same way, ie using QueryTask.
0 Kudos
RobertoPepato
Deactivated User
Thank you, thats do it! I can filter the result by a field and map it. My last question is, is it possible to set the input features, for instance, apply the geoprocessing to a subset of selected features.

Or is it possible to change geoprocessing parameters (like the buffer distance) the same way, ie using QueryTask.


You can pass a geometry instance to the query object. Doing that, the query results will be constrained to the area of the geometry parameter.

If you need a buffer over the geometry parameter, you can first use the GeometryService to bufferize your geometry and, after that, use it as the parameter to the query task.

https://developers.arcgis.com/en/javascript/jssamples/query_buffer.html

https://developers.arcgis.com/en/javascript/jsapi/geometryservice-amd.html#buffer
0 Kudos