Export Map

Description

The export operation is performed on a map service resource. The result of this operation is a map image resource. This resource provides information about the exported map image such as its URL, its width and height, extent and scale.

Apart from the usual response formats of html and json, users can also request a format called image while performing this operation. When users perform an export with the format of image, the server responds by directly streaming the image bytes to the client. One must note that with this approach you don't get any information associated with the exported map other than the actual image.

Note that the extent displayed in the exported map image may not exactly match the extent sent in the bbox parameter when the aspect ratio of the image size does not match the aspect ratio of thebbox. The aspect ratio is the height divided by the width. In these cases the extent is re-sized to prevent map images from appearing stretched. The exported map's extent is sent along with the json and html responses and may be used in client side calculations. So it is important that the client-side code update its extent based on the response.

New in 10.5

New in 10.1

New in 10.0

Users can provide arguments to the export operation as query parameters. These parameters include the request extent, size information, layer information, transparency etc. The parameter details are provided in the parameters table below.

Request Parameters

Parameter

Details

f

Description: The response format. The default response format is html. If the format is image, the image bytes are directly streamed to the client.

Values: html | json | image | kmz

bbox

Description: (Required) The extent (bounding box) of the exported image. Unless the bboxSR parameter has been specified, the bbox is assumed to be in the spatial reference of the map.

Syntax: <xmin>, <ymin>, <xmax>, <ymax>

Example: bbox=-104,35.6,-94.32,41

The bbox coordinates should always use a period as the decimal separator even in countries where traditionally a comma is used.

size

Description: The size width *height) of the exported image in pixels. If the size is not specified, an image with a default size of 400 * 400 will be exported.

Syntax: <width>, <height>

Example: size=600,550

dpi

Description: The device resolution of the exported image (dots per inch). If the dpi is not specified, an image with a default DPI of 96 will be exported.

Example: dpi=200

imageSR

Description: The spatial reference of the exported image.

The spatial reference can be specified as either a well-known ID or as a spatial reference json object.

If the imageSR is not specified, the image will be exported in the spatial reference of the map.

bboxSR

Description: The spatial reference of the bbox.

The spatial reference can be specified as either a well-known ID or as a spatial reference json object.

If the bboxSR is not specified, the bbox is assumed to be in the spatial reference of the map.

format

Description: The format of the exported image. The default format is .png.

Values: png | png8 | png24 | jpg | pdf | bmp | gif | svg | svgz | emf | ps | png32

NoteNote:

Support for the png32 format was added at 9.3.1. This format is only available for map services whose supportedImageFormatTypes property includes PNG32.

layerDefs

Description: Allows you to filter the features of individual layers in the exported map by specifying definition expressions for those layers. Definition expression for a layer that is published with the service will be always honored.

NoteNote:

When filtering the features of individual layers in a mosaic dataset, the client must explicitly specify the definition expression on the parent mosaic dataset layer. The definition expression will not be honored if it is specified on any of the child layers.

Simple syntax is no longer supported starting 10.5.

Syntax: { "<layerId1>" : "<layerDef1>" , "<layerId2>" : "<layerDef2>" }

Where layerId1, layerId2 are the layer ids returned by the map service resource.

layers

Description: Determines which layers appear on the exported map. There are four ways to specify which layers are shown:

  • show: Only the layers specified in this list will be exported.
  • hide: All layers except those specified in this list will be exported.
  • include: In addition to the layers exported by default, the layers specified in this list will be exported.
  • exclude: The layers exported by default excluding those specified in this list will be exported.

Syntax: [show | hide | include | exclude]:layerId1,layerId2

Where layerId1, layerId2 are the layer ids returned by the map service resource.

Example: layers=show:2,4,7

CautionCaution:

Showing or excluding group layers also shows or excludes all groups and sublayers within the group layer (assuming they draw by default). For example, if you want to show group layer 0 and layer 2 is a sublayer of this group, layer 2 will also display. The same logic applies when excluding a group layer.

transparent

Description: If true, the image will be exported with the background color of the map set as its transparent color. The default is false. Only the .png and .gif formats support transparency. Internet Explorer 6 does not display transparency correctly for png24 image formats.

Values: true | false

time

Description: The time instant or time extent of the exported map image.

Time instant:

Syntax: time=<timeInstant>

Example: time=1199145600000 (1 Jan 2008 00:00:00 GMT)

Time extent:

Syntax: time=<startTime>, <endTime>

Example: time=1199145600000, 1230768000000 (1 Jan 2008 00:00:00 GMT to 1 Jan 2009 00:00:00 GMT)

A null value specified for start time or end time will represent infinity for start or end time respectively (for example, time=null,1230768000000).

layerTimeOptions

Description: The time options per layer. Users can indicate whether or not the layer should use the time extent specified by the time parameter or not, whether to draw the layer features cumulatively or not and the time offsets for the layer.

Syntax:

{
  "<layerId1>" : {
    //If true, use the time extent specified by the time parameter
    "useTime" : < true | false >,
    //If true, draw all the features from the beginning of time for that data
    "timeDataCumulative" : < true | false >,
    //Time offset for this layer so that it can be overlaid on the top of a previous or future time period
    "timeOffset" : <timeOffset1>,
    "timeOffsetUnits" : "<esriTimeUnitsCenturies | esriTimeUnitsDays | esriTimeUnitsDecades | 
                             esriTimeUnitsHours | esriTimeUnitsMilliseconds | esriTimeUnitsMinutes | 
                             esriTimeUnitsMonths | esriTimeUnitsSeconds | esriTimeUnitsWeeks | esriTimeUnitsYears |
                             esriTimeUnitsUnknown>"
  },
  "<layerId2>" : {
    "useTime" : < true | false >,
    "timeDataCumulative" : < true | false >,
    "timeOffsetOffset" : <timeOffset2>,
    "timeOffsetUnits" : "<timeOffsetUnits2>"
  }
}

Example:

{
  "0" : {
    "useTime" : true,
    "timeDataCumulative" : false,
    "timeOffset" : 1,
    "timeOffsetUnits" : "esriTimeUnitsYears"
  },
  "3" : {
    "useTime" : false
  }
}

dynamicLayers

//This option was added at 10.1.

Description: Use dynamicLayers parameter to modify the layer drawing order, change layer drawing info, and change layer data source version for this request. New layers (dataLayer) can also be added to the dynamicLayers based on the map service registered workspaces.

The order of dynamicLayers array defines the layer drawing order. The first element of the dynamicLayers array draws on top of all other layers.

NoteNote:
  • When defining a dynamic layer, if the layer source is of type mapLayer, then use the id in layer resource as the mapLayerId for the dynamic layer.
  • If the layer source is a dataLayer based on a data table ( table or queryTable dataSource), then set drawingInfo.
  • transparency is on a scale of 1-100, where 0 is opaque and 100 is 100% transparent.
  • Use scaleSymbols to turn off scaling symbols on a layer that reports canScaleSymbols to be true on the layer resource.
  • Use showLabels to turn on/off labeling on a layer that has labels (hasLabels set to true on layer resource).
  • To turn on labels on a layer that does not have labels defined on it, set showLabels to true and use labelingInfo to specify labels.
  • Dynamic layers support both the Standard and Maplex labeling engines. The labeling engine that would be used is dependent on the one that was set in the map document used to create the map service.

Syntax:

[
  {
    "id": <layerOrTableId>,
    "source": <layer source>,
    "definitionExpression": "<definitionExpression>",
    "drawingInfo": 
    {
      "renderer": <renderer>,
      "transparency": <transparency>,
      "scaleSymbols": <true | false >,
      "showLabels": <true | false >,
      "labelingInfo": <labeling info>
    },
    "layerTimeOptions":
    {
      "useTime" : <true | false>,
      "timeDataCumulative" : <true | false>,
      "timeOffset" : <timeOffset>,
      "timeOffsetUnits" : "<esriTimeUnitsCenturies | esriTimeUnitsDays | esriTimeUnitsDecades | 
                             esriTimeUnitsHours | esriTimeUnitsMilliseconds | esriTimeUnitsMinutes | 
                             esriTimeUnitsMonths | esriTimeUnitsSeconds | esriTimeUnitsWeeks | esriTimeUnitsYears |
                             esriTimeUnitsUnknown>"
    }
  },
  {
    "id": <layerOrTableId>,
    "source": <layer source>,
    "definitionExpression": "<definitionExpression>",
    "drawingInfo": 
    {
      "renderer": <renderer>,
      "transparency": <transparency>,
      "scaleSymbols": <true | false >,
      "showLabels": <true | false >,
      "labelingInfo": <labeling info>
    },
    "layerTimeOptions":
    {
      "useTime" : <true | false>,
      "timeDataCumulative" : <true | false>,
      "timeOffset" : <timeOffset>,
      "timeOffsetUnits" : "<esriTimeUnitsCenturies | esriTimeUnitsDays | esriTimeUnitsDecades | 
                             esriTimeUnitsHours | esriTimeUnitsMilliseconds | esriTimeUnitsMinutes | 
                             esriTimeUnitsMonths | esriTimeUnitsSeconds | esriTimeUnitsWeeks | esriTimeUnitsYears |
                             esriTimeUnitsUnknown>"
    }
  }
]

Example:

[
  //disable time on existing map service layer and turn off labels
  {
    "id": 501,
    "source":
    {
      "type": "mapLayer",
      "mapLayerId": 0
    },
    "drawingInfo":
    {
	  "showLabels": false
    },
    "layerTimeOptions":
    {
	  "useTime": false
    }
  },
  //add a new layer from registered workspace and label features with a feature attribute value {TaxLotId]
  {
    "id": 502,
    "source":
    {
      "type": "dataLayer",
      "dataSource":
      {
        "type": "table",
        "workspaceId": "MAP",
        "dataSourceName": "MAP.user1.Taxlots"
      }
    },
    "drawingInfo": 
    {
      "renderer":
      {
        "type": "simple",
        "symbol":
        {
          "type" : "esriSFS", 
          "style" : "esriSFSSolid", 
          "color" : [166,36,0,255], 
          "outline" : 
          {
            "type" : "esriSLS", 
            "style" : "esriSLSSolid", 
            "color" : [110,110,110,255], 
            "width" : 1.0
          }
        },
        "label": "TaxLots",
        "description": ""
      },
      "transparency": 60,
      "showLabels": true,
      "labelingInfo":
      [
        {
          "labelPlacement": "esriServerPolygonPlacementAlwaysHorizontal",
          "labelExpression": "[TaxLotId]",
          "useCodedValues": false,
          "symbol": 
          {
            "type": "esriTS",
            "color": [255,255,0,255],
            "verticalAlignment": "bottom",
            "horizontalAlignment": "left",
            "font": 
            {
              "family": "Arial",
              "size": 12,
              "style": "normal",
              "weight": "bold",
              "decoration": "none"
            }
          },
          "minScale": 15000,
          "maxScale": 30000,
          "where": ""
        }
      ]
    }
  },
  //change the Version of existing map service layer
  {
    "id": 503,
    "source":
    {
      "type": "mapLayer",
      "mapLayerId": 1,
      "gdbVersion": "USER1"
    },
    "definitionExpression": "neighborhood = 'French Quarter'"
  },
  //add a raster from registered workspace
  {
    "id": 504,
    "source":
    {
      "type": "dataLayer",
      "dataSource":
      {
        "type": "raster",
        "workspaceId": "rasterWS",
        "dataSourceName": "NewOrleans.tif"
      }
    },
    "drawingInfo": 
    {
      "transparency": 0
    }
  }
]

gdbVersion

//This option was added at 10.1.

Description: Use this parameter to specify the geodatabase version.

Syntax: gdbVersion=<geodatabase version>

Example: gdbVersion=sde.USER1

mapScale

//This option was added at 10.1.

Description: Use this parameter to export a map image at a specific scale, with the map centered around the center of the specified bounding box (bbox).

Syntax: mapScale=<scale>

Examples: mapScale=5000000, mapScale=5E6

rotation

Description: Use this parameter to export a map image rotated at a specific angle, with the map centered around the center of the specified bounding box (bbox). It could be positive or negative number.

Syntax: rotation=<degree>

Examples: rotation=45 returns a map image rotated 45° counter-clockwise

datumTransformations

//This option was added at 10.5

Description: Use this parameter to apply one or more datum transformations to the map when imageSR is different than the map service's spatial reference. It is an array of transformation elements.

Transformations specified here are used to project features from layers within a map service to imageSR.

Note: while specifying transformation, you need to think about which datum transformation best applicable to project a layer(s) (not the map service) to the imageSR. sourceSpatialReference property in a layer resource reports which spatial reference features are stored in the source dataset.

For a list of valid datum transformation ID values and well-known text strings, see Geographic transformations.

Syntax: datumTransformations=[wkid1, wkid2].

Examples: datumTransformations=[1623, 4078] to apply multiple transformations.

Syntax: datumTransformations=[{<dt1>}, {<dt2>}].

Examples: datumTransformations=[{"wkid":108889}, {"geoTransforms":[{"wkid":108889,"transformForward":true},{"wkid":1622,"transformForward":false}]}] to apply multiple transformations including a composite transformation.

For more information on datum transformation, please see transformation parameter in Project operation.

mapRangeValues

//This option was added at 10.5

Description: Allows you to filter features in the exported map from all layer that are within the specified range instant or extent.

Note: Check rangeInfos at the layer resources for the available ranges.

Syntax:

[
  {
    "name" : "<rangeName1>",           //range id
    "value"   : <value> |               //single value or 
                [ <value1>, <value2> ] //a value-range 
                     // null is allowed in value-range case -- that means infinity
                     // e.g. [null, 1500] means all features with values <= 1500
                     // [1000, null] means all features with values >= 1000

  },
  {
    "name" : "<rangeName2>",
    "value" : <value> |  [ <value3>, <value4> ]
  }
]&

Example:

[{
  "name" : "salinity",
  "value" : 5            //a range instant (or single) value passed

 }, {
  "name" : "elevation",
  "value" : [1000, 1500] //a range extent is passed

}]

layerRangeValues

//This option was added at 10.5

Description: Allows you to filter features for each individual layer that are within the specified range instant or extent.

Note: Check rangeInfos at the layer resources for the available ranges.

Syntax:

{
  "<layerId1>" : [
    {
      "name" : "<rangeName1>",           //range id
      "value"   : <value> |               //single value or 
                  [ <value1>, <value2> ] //a value-range 
                       // null is allowed in value-range case -- that means infinity
                       // e.g. [null, 1500] means all features with values <= 1500
                       // [1000, null] means all features with values >= 1000

    },
    {
      "name" : "<rangeName2>",
      "value" : <value> |  [ <value3>, <value4> ]
    }
  ],
  "<layerId2>" : [
    {
      "name" : "<rangeName1>",
      "value"   : <value> | [ <value1>, <value2> ]

    }
  ]
}&

Example:

{
  "0" : [
    {
      "name" : "salinity",
      "value" : 5            //a range instant (or single) value passed
    },
    {
      "name" : "elevation",
      "value" : [1000, 1500] //a range extent is passed
    }
  ],
  "1" : [
    {
      "name" : "floor",
      "value" : [null, 5]   //selects features with values <= 5
    }
  ]
}

layerParameterValues

//This option was added at 10.5

Description: Allows you to filter the features of individual layers in the exported map by specifying value(s) to an array of pre-authored parameterized filters for those layers. When value is not specified for any parameter in a request, the default value, that is assigned during authoring time, gets used instead.

When a parameterInfo allows multiple values, you must pass them in an array.

Note: Check parameterInfos at the layer resources for the available parameterized filters, their default values and expected data type.

Syntax:

[
   {
     "<layerId1>" : {
       "<parameterName1>" : <value>,               //when the multipleValues=false in the parameterInfo
       "<parameterName2>" : [<value1> | <value2>]  //when the multipleValues=true in the parameterInfo
     },
     "<layerId2>" : {
       "<parameterName3>" : <value>
    }
  }
]&

Example:

[
   {
     "0" : {
       "floor" : 10,
       "incidentDate" : 1475877014000    //date time value needs to be passed in as epoch value
     },
     "1" : {
       "crimeType" : ["burglary", "theft"]
    }
  }
]&

Example Usage

Example 1: Export a map. Include only the bounding box.

http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/export?bbox=-127.8,15.4,-63.5,60.5

Example 2: Export a map. Change imageSR to 102004 (USA_Contiguous_Lambert_Conformal_Conic projection):

http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/export?bbox=-127.8,15.4,-63.5,60.5&bboxSR=&layers=&size=&imageSR=102004&format=&transparent=false&dpi=&f=html

Example 3: Export a map. Change imageSR to 102004 (USA_Contiguous_Lambert_Conformal_Conic projection), image size to a width and height of 800x600, format to .gif, and transparent to false.

http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/export?bbox=-115.8,30.4,-85.5,50.5&bboxSR=&layers=&size=800,600&imageSR=102004&format=gif&transparent=false&dpi=&f=html

Example 4: Export the same map as above but change the output format to pretty json (f=pjson).

http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/export?bbox=-115.8,30.4,-85.5,50.5&bboxSR=&layers=&size=800,600&imageSR=102004&format=gif&transparent=false&dpi=&f=pjson

Example 5: Export a map with dynamic layers. Update an existing map layer symbology.

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/export?bbox=-183.78001472868405,16.300709121618663,-61.406854669684265,74.03030803096895&bboxSR=&layers=&layerDefs=&size=&imageSR=&format=png&transparent=false&dpi=&time=&layerTimeOptions=&dynamicLayers=[{"id":101,"source":{"type":"mapLayer","mapLayerId":3},"drawingInfo":{"renderer": {"type":"simple", "symbol": {"type":"esriSFS","style":"esriSFSSolid","color":[255,0,0,255],"outline":{"type":"esriSLS","style":"esriSLSSolid","color":[0,255,0,255],"width":1}}}}}]&gdbVersion=&f=html

JSON Response Syntax

{"href" : "<href>","width" : <width>,"height" : <height>,"extent" : {<envelope>},"scale" : <scale>}

JSON Response Example

{"href" : "http://atlantic/arcgisoutput/_ags_map42ef5eae899942a9b564138e184a55c9.png","width" : 400,"height" : 400,"extent" : { "xmin" : -109.55, "ymin" : 25.76, "xmax" : -86.39, "ymax" : 49.94, "spatialReference" : {"wkid" : 4326, "latestWkid" : 4326}},"scale" : 2.53E7}

3/3/2017