Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/support
esri/workers
Class: ScaleDependentRenderer

require(["esri/renderers/ScaleDependentRenderer"], function(ScaleDependentRenderer) { /* code goes here */ });

Description

(Added at v3.7)
ScaleDependentRenderer provides the capability to apply multiple scale-dependent renderers to a layer. Each renderer is only applied to the layer at specific scale range or zoom range.

More information on working with rendering, smart mapping, and using visual variables can be found in the Data Visualization guide topic and the multiple samples referenced within this topic.

Samples

Search for samples that use this class.

Class hierarchy

esri/renderers/Renderer
|_esri/renderers/ScaleDependentRenderer

Constructors

NameSummary
new ScaleDependentRenderer(options?)Create a ScaleDependentRenderer.

Properties

NameTypeSummary
rangeTypeStringIndicates whether rendererInfos uses zoom range or scale range.
rendererInfosObjectAn array of objects, where each object defines a renderer and the zoom/scale range to which it applies.

Methods

NameReturn typeSummary
addRendererInfo(info)ScaleDependentRendererAdds the specified renderer info to the array of existing renderers.
getColor(graphic, options?)ColorGets the color for the Graphic.
getOpacity(graphic, options?)NumberReturns the opacity value for the specified graphic.
getRendererInfo(graphic)ObjectReturns the renderer info for the input graphic.
getRendererInfoByScale(scale)ObjectReturns the renderer info for the specified scale.
getRendererInfoByZoom()ObjectReturns the rendererInfo for the specified zoom level.
getRotationAngle(graphic, options?)NumberReturns the angle of rotation (in degrees) for the graphic calculated using rotationInfo.
getSize(graphic, options?)NumberReturn the symbol size (in pixels) for the graphic, calculated using sizeInfo.
getSymbol(graphic)SymbolGets the symbol for the Graphic.
setRendererInfos(infos)ScaleDependentRendererReplaces existing rendererInfos with new ones.
toJson()ObjectConverts object to its ArcGIS Server JSON representation.
Constructor Details

new ScaleDependentRenderer(options?)

Create a ScaleDependentRenderer.
Parameters:
<Object> options Optional Various options to configure this renderer. See the list below for details.
options properties:
<Object[]> rendererInfos Optional An array of objects where each object defines a renderer and the zoom or scale range to which it applies.
  • All objects must have either a zoom range or scale range. You cannot define rendererInfos with a mixture of zoom range and scale range.
  • When using zoom range, make sure it falls within the min zoom and max zoom values allowed by the map.
rendererInfos: [
  {
    "renderer": <Renderer>,
    "minZoom": <Number>,
    "maxZoom": <Number>,
  },
...
]
or
  {
    "renderer": <Renderer>,
    "minScale": <Number>,
    "maxScale": <Number>,
  },
...
Sample:
var renderer1 = new DotDensityRenderer({
  fields: [{
    name: "M163_07",
    color: new Color([52, 114, 53])
  }],
  dotValue: 4000,
  dotSize: 2
});

var renderer2 = new DotDensityRenderer({
  fields: [{
    name: "M163_07",
    color: new Color([52, 114, 53])
  }],
  dotValue: 1000,
  dotSize: 2
});

var scaleDependentRenderer = new ScaleDependentRenderer({
  rendererInfos: [{
    renderer: renderer1,
    maxScale: 10000000,
    minScale: 20000000
  }, {
    renderer: renderer2,
    maxScale: 5000000,
    minScale: 10000000
  }]
});

layer.setRenderer(scaleDependentRenderer);
Property Details

<String> rangeType

Indicates whether rendererInfos uses zoom range or scale range.
Known values: "zoom" | "scale"

<Object> rendererInfos

An array of objects, where each object defines a renderer and the zoom/scale range to which it applies.
Method Details

addRendererInfo(info)

Adds the specified renderer info to the array of existing renderers. In order to view the change call the GraphicsLayer redraw method.
Parameters:
<Object> info Required An object as defined in the rendererInfos property.

getColor(graphic, options?)

Gets the color for the Graphic. (Added at v3.8)
Return type: Color
Parameters:
<Graphic> graphic Required Graphic to get color from.
<Object> options Optional This optional parameter supports colorInfo. If none is provided, the Renderer.colorInfo will be used.

getOpacity(graphic, options?)

Returns the opacity value for the specified graphic. This is calculated using the opacityInfo definition. (Added at v3.11)
Return type: Number
Parameters:
<Graphic> graphic Required Returns the opacity value appropriate for the given graphic. This value is calculated based on the opacityInfo definition.
<Object> options Optional This optional parameter supports opacityInfo. If none is provided, the Renderer.opacityInfo will be used.

getRendererInfo(graphic)

Returns the renderer info for the input graphic. Note that the graphic should be part of a GraphicsLayer (or one of its sub-classes) that is added to the map.
Return type: Object
Parameters:
<Graphic> graphic Required The graphic for which you want to get renderer info.

getRendererInfoByScale(scale)

Returns the renderer info for the specified scale.
Return type: Object
Parameters:
<Number> scale Required Returns the renderer info for the specified scale.

getRendererInfoByZoom()

Returns the rendererInfo for the specified zoom level.
Return type: Object

getRotationAngle(graphic, options?)

Returns the angle of rotation (in degrees) for the graphic calculated using rotationInfo. (Added at v3.7)
Return type: Number
Parameters:
<Graphic> graphic Required An input graphic for which you want to get the angle of rotation.
<Object> options Optional This optional parameter supports rotationInfo. If none is provided, the Renderer.rotationInfo will be used.

getSize(graphic, options?)

Return the symbol size (in pixels) for the graphic, calculated using sizeInfo. (Added at v3.7)
Return type: Number
Parameters:
<Graphic> graphic Required The graphic for which you want to calculate the symbol size.
<Object> options Optional This optional parameter supports sizeInfo. If none is provided, the Renderer.sizeInfo will be used.

getSymbol(graphic)

Gets the symbol for the Graphic.
Return type: Symbol
Parameters:
<Graphic> graphic Required Graphic to symbolize. Used when creating a custom renderer.

setRendererInfos(infos)

Replaces existing rendererInfos with new ones. The infos argument is an array of objects as described in the rendererInfos property. For the changes to take effect, call GraphicsLayer redraw after calling this method.
Parameters:
<Object> infos Required An array of objects as defined in the rendererInfos property.

toJson()

Converts object to its ArcGIS Server JSON representation. (Added at v2.1)
Return type: Object
Show Modal