dojo.require("esri.tasks.GenerateRendererTask");
Description
(Added at v2.6)
The GenerateRendererTask class creates a renderer based on a classification definition and optional where clause. The classification definition is used to define the base symbol and color ramp for the renderer. The output renderer can be applied to graphics layers, feature layers or dynamic layers. The GenerateRendererTask is available for map service or tables that support the
generateDataClasses
operation (version 10.1 or greater).
Samples
Search for
samples that use this class.
Constructors
Methods
Events
[ On Style Events | Connect Style Event ]
All On Style event listeners receive a single event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.
Events
complete | {
renderer: <Renderer >
} | Fired when the classification operation is complete. |
error | {
error: <Error >
} | Fired when an error occurs during task execution. |
Constructor Details
Creates a new GenerateRendererTask object.
Parameters:
<String > url |
Required |
URL to a layer in a map service or table. Requires an ArcGIS Server version 10.1 or greater service that supports the generateDataClasses operation. |
<Object > options |
Optional |
Optional parameters. See options list. |
options
properties:
<Boolean > checkValueRange |
Optional |
Prior to ArcGIS Server 10.2, map server/feature service only sample 1000 features to generate the renderer when using GenerateRenderer operation, which mean if there are more than 1000 features, it may run into the case that some feature will not be categorized into any breaks/unique values. If setting "checkValueRange" as true, it will query the service and find the minValue/maxValue of all the features and assign it to the min/max of the renderer. Starting ArcGIS Server 10.2, the limit is 100,000. (Add at v3.7) |
<String > gdbVersion |
Optional |
Specify the geodatabase version to display. (As of v2.7). Requires ArcGIS Server service 10.1 or greater |
Sample:
var countiesUrl = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/2";
var generateRenderer = new esri.tasks.GenerateRendererTask(countiesUrl);
Method Details
Perform a classification on the layer or table resource. Upon successful completion of the classification operation the onComplete
event is fired and the optional callback function is invoked. The result is a renderer object that can be applied to graphics layers, feature layers or dynamic layers.
Parameters:
<GenerateRendererParameters > generateRendererParameters |
Required |
A GenerateRendererParameters object that defines the classification definition and an optional where clause. |
<Function > callback |
Optional |
This function will be called when the operation is complete. The arguments passed to this function are the same as the OnComplete event. |
<Function > errback |
Optional |
An error object is returned if an error occurs on the Server during task execution. |
Sample:
var params = new esri.tasks.GenerateRendererParameters();
params.classificationDefinition = classDef;
params.where = layerDef;
generateRenderer.execute(params, applyRenderer, errorHandler);
Event Details
[ On Style Events | Connect Style Event ]
Fired when the classification operation is complete. Should be used in favor of onComplete. (Added at v3.5)
Event Object Properties:
<Renderer > renderer |
A renderer object that can be applied to a feature layer, graphics layer or dynamic layer. |
Fired when an error occurs during task execution. (Added at v3.6)
Fired when the classification operation is complete.
Event Object Properties:
<Renderer > renderer |
A renderer object that can be applied to a feature layer, graphics layer or dynamic layer. |
Sample:
dojo.connect(generateRenderer,function(renderer){
featureLayer.setRenderer(renderer);
featureLayer.refresh();
});
Fired when an error occurs during task execution.