Class: ArcGISDynamicMapServiceLayer

Description

dojo.require("esri.layers.agsdynamic");

Allows you to work with a dynamic map service resource exposed by the ArcGIS Server REST API. A dynamic map service generates images on the fly. For cached map services, see ArcGISTiledMapServiceLayer.

If the first layer added to the map is an ArcGISDynamicMapServiceLayer, the map will take on the projection of this layer.

Samples

Search for samples that use this class.  

Class hierarchy

esri.Layer
  |_ esri.layers.DynamicMapServiceLayer
        |_ esri.layers.ArcGISDynamicMapServiceLayer

Constructor

Constructor Description
esri.layers.ArcGISDynamicMapServiceLayer(url, options?) Creates a new ArcGISDynamicMapServiceLayer object. A URL is a required parameter. This layer also takes some optional parameters. These optional parameters can be included in any order.

Properties

Property Type Description
capabilities String Capabilities of the map service, possible values are Map, Query and Data. Only available if the map service is published using ArcGIS Server version 10 or greater.
copyright String Copyright string as defined by the map service.
description String Map description as defined by the map service.
disableClientCaching Boolean When true, images are always requested from the server and the browser's cache is ignored. This should be used when the data supporting the map service changes frequently.
dpi Number The output dpi of the dynamic map service layer.
imageFormat String The output image type. As of ArcGIS Server 9.3.1, the list of supported image formats is included in the description of Map Services in Services Directory under "Supported Image Format Types". In addition, as of ArcGIS Server 9.3.1, optimized map services can produce true PNG32 images.
imageTransparency Boolean Whether or not background of dynamic image is transparent.
layerDefinitions String[] Sets the layer definitions used to filter the features of individual layers in the map service. Layer definitions with semicolons or colons are supported at version 2.0 if using a map service published using ArcGIS Server 10.0
layerInfos LayerInfo[] Returns the available layers in service and their default visibility.
layerTimeOptions LayerTimeOptions[] Returns the current layer time options if applicable. Use the setLayerTimeOptions method to modify the time options.
timeInfo TimeInfo Temporal information for the layer, such as time extent. If this property is null or not specified, then the layer does not support time-related operations.
units String Default units of the layer as defined by the service. If the layer is the base map, the map is in these units.
useMapImage Boolean When true, the image is saved to the server, and a JSON formatted response is sent to the client with the URL location of the image. A second call is automatically made to the server to retrieve the image. This value is set in the constructor using useMapImage. Deprecated at v2.0.
version Number The version of ArcGIS Server where the map service is published. Examples are 9.3, 9.3.1, 10, 10.01.
visibleLayers Number[] Gets the visible layers of the exported map.

Methods

Method Return Value Description
exportMapImage(imageParameters?, callback?) none Exports a map using values as specified by ImageParameters. On completion, MapImage is returned.
setDefaultLayerDefinitions() none Resets all layer definitions to those defined in the service.
setDefaultVisibleLayers() none Clears the visible layers as defined in setVisibleLayers, and resets to the default layers of the map service.
setDisableClientCaching(disable) none Sets whether images are always requested from the server and the browser's cache is ignored. This should be used when the data supporting the map service changes frequently.
setDPI(dpi) none Sets the dpi of the exported map. The default value is 96.
setImageFormat(imageFormat) none Sets the image format of the exported map.
setImageTransparency(transparent) none Sets the background of a dynamic image to transparent.
setLayerDefinitions(layerDefinitions) none Sets the layer definitions used to filter the features of individual layers in the map service.
setLayerTimeOptions(options) none Sets the time-related options for the layer.
setVisibleLayers(ids) none Sets the visible layers of the exported map. By default, the visible layers are as defined by the default visibility in LayerInfo.

Events

Event Description
onMapImageExport(mapImage) Fires when the map export is completed.
Constructor Detail

esri.layers.ArcGISDynamicMapServiceLayer(url, options?)

Creates a new ArcGISDynamicMapServiceLayer object. A URL is a required parameter. This layer also takes some optional parameters. These optional parameters can be included in any order.
Parameters:
<String> url Required URL to the ArcGIS Server REST resource that represents a map service. An example is http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer. For more information on constructing a URL, see The Services Directory and the REST API.
<Object> options Optional Optional parameters. See options list.
Options:
<String> id Id to assign to the layer. If not assigned, esri.Map assigns value.
<ImageParameters> imageParameters Represents the image parameter options.
<Number> opacity Initial opacity or transparency of layer. Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency. The default value is 1.0.
<Boolean> useMapImage By default, images are exported in MIME format, and the image is streamed to the client. When useMapImage is set to true, the image is saved to the server, and a JSON formatted response is sent to the client with the URL location of the image. A second call is automatically made to the server to retrieve the image. This methodology is required for secure services that go through a proxy server. In this situation, a map image cannot be streamed. (As of v1.2) Deprecated at v2.0. Prior to v2.0 this option was used to configure the map to use the proxy all the time. This is not the optimal behavior so at v2.0 the switch to use the proxy will automatically happen if needed.
<Boolean> visible Initial visibility of the layer. Default is true.
Code snippets:
new esri.layers.ArcGISDynamicMapServiceLayer(
  "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Louisville/LOJIC_LandRecords_Louisville/MapServer",
  {useMapImage:true});
Properties Detail

<String> capabilities

Capabilities of the map service, possible values are Map, Query and Data. Only available if the map service is published using ArcGIS Server version 10 or greater. (As of v2.1)
Code snippets:
console.log(layer.capabilities);

<String> copyright

Copyright string as defined by the map service.

<String> description

Map description as defined by the map service.

<Boolean> disableClientCaching

When true, images are always requested from the server and the browser's cache is ignored. This should be used when the data supporting the map service changes frequently. (As of v1.2)
Known values: true | false
Default value: false
See also:
setDisableClientCaching  

<Number> dpi

The output dpi of the dynamic map service layer.
Default value: 96
See also:
setDPI  

<String> imageFormat

The output image type. As of ArcGIS Server 9.3.1, the list of supported image formats is included in the description of Map Services in Services Directory under "Supported Image Format Types". In addition, as of ArcGIS Server 9.3.1, optimized map services can produce true PNG32 images.
Known values: png | png8 | png24 | png32 | jpg | pdf | bmp | gif | svg
Default value: png8
See also:
setImageFormat  

<Boolean> imageTransparency

Whether or not background of dynamic image is transparent.
Known values: true | false
Default value: true
See also:
setImageTransparency  

<String[]> layerDefinitions

Sets the layer definitions used to filter the features of individual layers in the map service. Layer definitions with semicolons or colons are supported at version 2.0 if using a map service published using ArcGIS Server 10.0 (As of v1.2)
See also:
setLayerDefinitions  

<LayerInfo[]> layerInfos

Returns the available layers in service and their default visibility.

<LayerTimeOptions[]> layerTimeOptions

Returns the current layer time options if applicable. Use the setLayerTimeOptions method to modify the time options. (As of v2.0)
See also:
setLayerTimeOptions  

<TimeInfo> timeInfo

Temporal information for the layer, such as time extent. If this property is null or not specified, then the layer does not support time-related operations. (As of v2.0)

<String> units

Default units of the layer as defined by the service. If the layer is the base map, the map is in these units.

<Boolean> useMapImage

When true, the image is saved to the server, and a JSON formatted response is sent to the client with the URL location of the image. A second call is automatically made to the server to retrieve the image. This value is set in the constructor using useMapImage. Deprecated at v2.0. Prior to v2.0 this option was used when some export map requests exceeded the limit of 2000 characters and it configured the map to use the proxy all the time. This is not the optimal behavior so at v2.0 the switch to use the proxy will automatically happen for long requests. (As of v1.2)
Known values: true | false
Default value: false

<Number> version

The version of ArcGIS Server where the map service is published. Examples are 9.3, 9.3.1, 10, 10.01. (As of v2.1)

<Number[]> visibleLayers

Gets the visible layers of the exported map. (As of v1.2)
See also:
setVisibleLayers  
Methods Detail

exportMapImage(imageParameters?, callback?)

Exports a map using values as specified by ImageParameters. On completion, MapImage is returned.
Return value: none
Input Parameters:
<ImageParameters> imageParameters Optional Input parameters assigned before exporting the map image.
<Function> callback Optional The function to call when the method has completed. The arguments in the function are the same as the onMapImageExport event.
See also:
onMapImageExport  

setDefaultLayerDefinitions()

Resets all layer definitions to those defined in the service. (As of v1.1)
Return value: none
See also:
setLayerDefinitions  

setDefaultVisibleLayers()

Clears the visible layers as defined in setVisibleLayers, and resets to the default layers of the map service.
Return value: none

setDisableClientCaching(disable)

Sets whether images are always requested from the server and the browser's cache is ignored. This should be used when the data supporting the map service changes frequently. (As of v1.2)
Return value: none
Input Parameters:
<Boolean> disable Required When true, client side caching is disabled.
Code snippets:
var layer = new esri.layers.ArcGISDynamicMapServiceLayer(
        "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSFields/MapServer");
layer.setDisableClientCaching(true);

See also:
disableClientCaching  

setDPI(dpi)

Sets the dpi of the exported map. The default value is 96.
Return value: none
Input Parameters:
<Number> dpi Required DPI value.
See also:
dpi  

setImageFormat(imageFormat)

Sets the image format of the exported map.
Return value: none
Input Parameters:
<String> imageFormat Required Valid values are png | png8 | png24 | jpg | pdf | bmp | gif | svg.
See also:
imageFormat  

setImageTransparency(transparent)

Sets the background of a dynamic image to transparent.
Return value: none
Input Parameters:
<Boolean> transparent Required Valid values are true | false. The default is "true".
See also:
imageTransparency  

setLayerDefinitions(layerDefinitions)

Sets the layer definitions used to filter the features of individual layers in the map service. If the layer definition expression is longer than approximately 2000 characters you will need to set up a proxy page. Prior to v2.0, you also need to set useMapImage to true.

Layer definitions with semicolons or colons are supported if using a map service published using ArcGIS Server 10.

Return value: none
Input Parameters:
<String[]> layerDefinitions Required An array containing each layer's definition.
Code snippets:

The layerDefinitions argument is an array of layer definition expressions such as in the code snippet below.

var layerDefinitions = [];
layerDefinitions[0] = "POPULATION > 5000000";
layerDefinitions[5] = "AREA > 100000";
dynamicMapServiceLayer.setLayerDefinitions(layerDefinitions);

Note that the array indices 0 and 5 are valid layer IDs, and POPULATION and AREA are valid attribute fields associated with the respective layers. Definition expressions for layers that are currently not visible will be ignored by the server.


setLayerTimeOptions(options)

Sets the time-related options for the layer. (As of v2.0)
Return value: none
Input Parameters:
<LayerTimeOptions[]> options Required Array of LayerTimeOptions objects that allow you to override how a layer is exported in reference to the map's time extent. There is one object per sub-layer. In the following example, array indices 2 and 5 are valid sub-layer IDs.
var timeOption1 = new esri.layers.LayerTimeOptions();
timeOption1.timeOffset = 4;
timeOption1.timeOffsetUnits = esri.layers.TimeInfo.UNIT_YEARS;

var options = [];
options[2]= timeOption1;
options[5] = timeOption2;
imageParameters.layerTimeOptions = options;
See also:
layerTimeOptions  

setVisibleLayers(ids)

Sets the visible layers of the exported map. By default, the visible layers are as defined by the default visibility in LayerInfo.
Return value: none
Input Parameters:
<Number[]> ids Required Array of layer IDs.
Code snippets:
var inputs = dojo.query(".list_item"), input;
visible = [];
for (var i=0, il=inputs.length; i
See also:
visibleLayers  

Events Detail

onMapImageExport(mapImage)

Fires when the map export is completed.
Arguments:
<MapImage> mapImage Contains the properties of a dynamically generated map image.
See also:
exportMapImage