Class: ArcGISDynamicMapServiceLayerE-mail This Topic Printable Version Give Us Feedback

Description

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.

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
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.
layerInfos LayerInfo[] Returns the available layers in service and their default visibility.
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.
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. 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.
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)
<Boolean> visible Initial visibility of the layer. Default is true.
Properties Detail

<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. (As of v1.2)
See also:
setLayerDefinitions  

<LayerInfo[]> layerInfos

Returns the available layers in service and their default visibility.

<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. (As of v1.2)
Known values: true | false
Default value: false

<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.
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. 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.
Return value: none
Input Parameters:
<String[]> layerDefinitions Required An array containing each layer's definition.

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.
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