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

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

Description

(Added at v1.0)
Allows you to work with a cached map service resource exposed by the ArcGIS Server REST API. A cached service accesses tiles from a cache instead of dynamically rendering images. For dynamic map services, see DynamicMapServiceLayer. For additional information on working with map service attribution please visit the official attribution in your app documentation.

Samples

Search for samples that use this class.

Class hierarchy

esri/layers/Layer
|_esri/layers/TiledMapServiceLayer
  |_esri/layers/ArcGISTiledMapServiceLayer

Constructors

NameSummary
new ArcGISTiledMapServiceLayer(url, options?)Creates a new ArcGISTiledMapServiceLayer object.

Properties

NameTypeSummary
attributionDataUrlStringThe URL, when available, where the layer's attribution data is stored.
capabilitiesStringCapabilities of the map service, possible values are Map, Query and Data.
classNameStringclass attribute of the layer's node.
copyrightStringCopyright string as defined by the map service.
credentialCredentialProvides credential information for the layer such as userid and token if the layer represents a resource that is secured with token-based authentication.
descriptionStringMap description as defined by the map service.
fullExtentExtentFull extent as defined by the map service.
hasAttributionDataBooleanWhen true, the layer has attribution data.
idStringID assigned to the layer.
infoTemplatesObjectA dictionary from the layer id to the layerInfoTemplateOptions object.
initialExtentExtentInitial extent as defined by the map service.
layerInfosLayerInfo[]Returns the available layers in service and their default visibility.
loadErrorErrorSet if the layer failed to load.
loadedBooleanWhen the layer is loaded, the value becomes "true", and layer properties can be accessed.
maxImageHeightNumberThe maximum image height, in pixels, that the map service will export.
maxImageWidthNumberThe maximum image width, in pixels, that the map service will export.
maxRecordCountNumberThe maximum number of results that can be returned from query, identify and find operations.
maxScaleNumberMaximum visible scale for the layer.
minScaleNumberMinimum visible scale for the layer.
opacityNumberOpacity or transparency of layer.
refreshIntervalNumberRefresh interval of the layer in minutes.
showAttributionBooleanWhen true, the layer's attribution is displayed on the map.
spatialReferenceSpatialReferenceThe spatial reference of the map service.
suspendedBooleanWhen true, the layer is suspended.
tileInfoTileInfoReturns TileInfo, which has information on the tiling schema.
timeInfoTimeInfoTemporal information for the layer, such as time extent.
unitsStringDefault units of the layer as defined by the service.
urlStringURL to the ArcGIS Server REST resource that represents a map service.
versionNumberThe version of ArcGIS Server where the map service is published.
visibleBooleanVisibility of the layer.
visibleAtMapScaleBooleanWhen true, the layer is visible at the current map scale.

Methods

NameReturn typeSummary
attr(name, value)LayerAdds a new attribute or changes the value of an existing attribute on the layer's node.
getAttributionData()DeferredAsynchronously returns custom data for the layer when available.
getMap()MapReturns reference to the map control the layer is added to.
getNode()HTMLElementReturns the layer's DOM node.
getTileUrl(level, row, column)StringMethod to implement when extending TiledMapServiceLayer.
hide()NoneSets the visibility of the layer to "false".
isVisibleAtScale(scale)BooleanReturns true if the layer is visible at the given scale.
refresh()NoneReloads all the tiles in the current view.
resume()NoneResumes layer drawing.
setExclusionAreas()ArraySpecify areas to not show tiles.
setInfoTemplates(infoTemplates)NoneSet the infoTemplates property.
setMaxScale(scale)NoneSet the maximum scale for the layer.
setMinScale(scale)NoneSet the minimum scale for the layer.
setOpacity(opacity)NoneSets the opacity of the layer.
setRefreshInterval(interval)LayerChanges the layer's refresh interval to the given value (in minutes).
setScaleRange(minScale, maxScale)NoneSet the scale range for the layer.
setVisibility(isVisible)NoneSets the visibility of the layer.
show()NoneSets the visibility of the layer to "true".
suspend()NoneSuspends layer drawing.

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

NameEvent ObjectSummary
error
{
  error: <Error>
}
Fires when there is a problem retrieving a layer.
load
{
  layer: <Layer>
}
Fires after layer properties for the layer are successfully populated.
opacity-change
{
  opacity: <Number>
}
Fires when the layer opacity has been changed, and returns an object with the opacity value.
refresh-interval-changeThis event is fired when the layer's refreshInterval is modified.
resumeFires when a layer resumes drawing.
scale-range-changeFires when a layer's minScale and/or maxScale is changed.
scale-visibility-changeFires when a layer's scale visibility changes.
suspendFires when a layer suspends drawing.
updateFires any time a layer has finished loading or updating itself.
update-end
{
  error: <Error>
}
Fires when a layer has finished updating its content.
update-startFires when a layer begins to update its content.
visibility-change
{
  visible: <Boolean>
}
Fires when the layer visibility has been changed, and returns an object with a Boolean visible property containing the new visibility value of the layer.
Constructor Details

new ArcGISTiledMapServiceLayer(url, options?)

Creates a new ArcGISTiledMapServiceLayer 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 at represents a map service. An example is https://www.example.com/arcgis/rest/services/Portland/Portland_ESRI_LandBase_AGO/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 properties:
<String> className Optional Class attribute to set for the layer's node.
<Number[]> displayLevels Optional

Lists which levels to draw.

In the following example, assume you have two layers. The first layer is an ArcGIS Online imagery basemap, and you want to use only levels 0 through 7. You also have a second layer with more recent street data that you want to use for levels 8 through 12.

require([
  "esri/map", "esri/layers/ArcGISTiledMapServiceLayer", ... 
], function(Map, ArcGISTiledMapServiceLayer, ... ) {
  var map = new Map( ... );
  var agoServiceURL = "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer";
  var agoLayer = new ArcGISTiledMapServiceLayer(agoServiceURL, { displayLevels:[0,1,2,3,4,5,6,7]});
  map.addLayer(agoLayer);
  ...
});


require([
  "esri/map", "esri/layers/ArcGISTiledMapServiceLayer", ... 
], function(Map, ArcGISTiledMapServiceLayer, ... ) {
  var map = new Map( ... );
  var myServiceURL = "https://myserver/ArcGIS/rest/services/myservice/MapServer";
  var myLayer = new ArcGISTiledMapServiceLayer(myServiceURL, { displayLevels:[8,9,10,11,12]});
  map.addLayer(myLayer);
  ...
});
<Array> exclusionAreas Optional An array of objects that define areas where a tiled map service should not display tiles. Each exclusion area object has the following properties:
  • minScale?: Number default: -1
  • maxScale?: Number default: -1
  • minZoom?: Number default: -1
  • maxZoom?: Number default: -1
  • geometry: esri/geometry/Extent
min/maxScale and min/maxZoom define the set of LODs where the exclusion is applied. If no value is defined for minScale or minZoom, the first LOD of the layer is used. If no value is defined for maxScale or maxZoom, the last LOD of the layer is used.

min/maxZoom take precedence over min/maxScale.

The value for geometry is of type Extent. Other geometry types might be supported in the future but are not currently supported. Geometry must be in the same spatial reference as the map. The exception is that a geographic extent (WGS84) can be used with web mercator maps and vice versa.

Example:
var exclusionAreas = [{
  minScale: 40000,
  maxScale: 9028,
  geometry: new Extent(
    13871520.850500003,
    3910293.086000003,
    14574034.873400003,
    4686306.161399998,
    new SpatialReference(102100)
  )
}]; 
<String> id Optional Id to assign to the layer. If not assigned, esri.Map assigns value.
<Object> infoTemplates Optional infoTemplates object. See the infoTemplates property for details.
<Number> opacity Optional 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.
<Number> refreshInterval Optional Refresh interval of the layer in minutes. Non-zero value sets up automatic layer refresh at the specified interval.
<Boolean> resampling Optional The purpose of resampling is to enlarge the image and fill in at the levels where there are no tiles available. When true, tile resampling is enabled. The default value is true for Esri's basemaps. For other services, it is initially undefined until the layer loads, then defaults to the value in the resourceInfo, or false if not specified in the resourceInfo. Prior to version 3.12, the default was false.

By specifying this option, it does not necessarily mean resampling to any scale will work. For example, a tiled map layer may not have data beyond level 15 in some areas (for example rural areas). But in other areas (for example metropolitan areas), it may have data down to level 19. Enabling resampling would draw images all over to the last level and deliver a consistent user experience. In areas with no data, blurred images display. The tiled services need to return a 404 for missing tiles to get this option to work. Note that 404s for missing tiles did not become the default for ArcGIS Server until 10.2. Added at 3.6, updated at 3.12
<Number> resamplingTolerance Optional Number of levels beyond the last level where tiles are available. If not specified, resampling is enabled at all levels where tiles are not available.
The tiled services need to return a 404 for missing tiles to get this option to work. Note that 404s for missing tiles did not become the default for ArcGIS Server until 10.2. Added at 3.6.
<Object> resourceInfo Optional Specify the metadata of the layer.
<Boolean> showAttribution Optional When true, the layer's attribution is displayed on the map. The default value is true. Added at v3.1
require([
  "esri/layers/ArcGISTiledMapServiceLayer", ... 
], function(ArcGISTiledMapServiceLayer, ... ) {
  var basemap = new ArcGISTiledMapServiceLayer(layerUrl, {
    showAttribution: false
  });
  ...
});
<String[]> tileServers Optional Array of REST endpoints that can be used to retrieve tile images. At version 2.7, layers hosted on ArcGIS Online will automatically use server.arcgisonline and services.arcgisonline.com as the tile servers.
<Boolean> visible Optional Initial visibility of the layer. The default value is true.
Sample:
require([
  "esri/layers/ArcGISTiledMapServiceLayer", ... 
], function(ArcGISTiledMapServiceLayer, ... ) {
  var tiledMapServiceLayer = new ArcGISTiledMapServiceLayer(  
  "https://server.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer");
  ...
});
require([
  "esri/layers/ArcGISTiledMapServiceLayer", ... 
], function(ArcGISTiledMapServiceLayer, ... ) {
  var tiledMapLayer = new ArcGISTiledMapServiceLayer(url, {
    tileServers: [
      "https://host.domain.com/ArcGIS/rest/services/BaseMaps/Terrain/MapServer",
      "https://host2.domain.com/ArcGIS/rest/services/BaseMaps/Terrain/MapServer"]
  });
  ...
});
Property Details

<String> attributionDataUrl

The URL, when available, where the layer's attribution data is stored. (Added at v3.1)

<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. (Added at v2.1)
Sample:

console.log(layer.capabilities);

<String> className

class attribute of the layer's node. (Added at v3.7)

<String> copyright

Copyright string as defined by the map service.

<Credential> credential

Provides credential information for the layer such as userid and token if the layer represents a resource that is secured with token-based authentication. This value is available after the layer has been loaded i.e. layer.loaded is true. (Added at v2.5)

<String> description

Map description as defined by the map service.

<Extent> fullExtent

Full extent as defined by the map service.

<Boolean> hasAttributionData

When true, the layer has attribution data. The default value is false. Use the getAttributionData method to retrieve this data as JSON. (Added at v3.1)
Known values: true | false

<String> id

ID assigned to the layer. If not assigned, esri.Map assigns value. By default, the ID of the layer is "layer" followed by a number. The ID can be user defined only in the layer constructor.
Sample:
  • Setting the layer ID in the layer constructor.
    require([
      "esri/layers/ArcGISDynamicMapServiceLayer", ... 
    ], function(ArcGISDynamicMapServiceLayer, ... ) {
      var population = new ArcGISDynamicMapServiceLayer("http://myserver/arcgis/rest/population/MapServer/Layers", {id:"population"});
      ...
    });
    
  • Setting the layer ID after a layer is initialized.
    population.id = "population";
    
  • Retrieving the layer ID.
    function getMapLayers() {
      for (var j=0, jl=map.layerIds.length; j<jl; j++) {
        var currentLayer = map.getLayer(map.layerIds[j]);
        alert("id: " + currentLayer.id);
      }
    }
    

<Object> infoTemplates

A dictionary from the layer id to the layerInfoTemplateOptions object. See the object specifications table below for properties of the layerInfoTemplateOptions object. (Added at v3.10)
Object Specifications:
<layerInfoTemplateOptions>
<InfoTemplate> infoTemplate Required The infoTemplate for the layer.
<String> layerUrl Required URL to the layer.
<Object> resourceInfo Required Metadata of the layer.
Sample:
var infoTemplates = {
  3: {
    infoTemplate: new InfoTemplate(),
    layerUrl: null
  }
};

<Extent> initialExtent

Initial extent as defined by the map service.

<LayerInfo[]> layerInfos

Returns the available layers in service and their default visibility.

<Error> loadError

Set if the layer failed to load. (Added at v3.9)

<Boolean> loaded

When the layer is loaded, the value becomes "true", and layer properties can be accessed. The onLoad event is also fired.
Known values: true | false

<Number> maxImageHeight

The maximum image height, in pixels, that the map service will export. Requires ArcGIS Server version 10.1 or greater. (Added at v2.6)

<Number> maxImageWidth

The maximum image width, in pixels, that the map service will export. Requires ArcGIS Server version 10.1 or greater. (Added at v2.6)

<Number> maxRecordCount

The maximum number of results that can be returned from query, identify and find operations. Requires ArcGIS Server version 10.1 or greater. (Added at v2.6)

<Number> maxScale

Maximum visible scale for the layer. If the map is zoomed in beyond this scale, the layer will not be visible. A value of 0 means the layer does not have a maximum scale. The default value is 0. (Added at v3.1)

<Number> minScale

Minimum visible scale for the layer. If the map is zoomed out beyond this scale, the layer will not be visible. A value of 0 means the layer does not have a visible scale. The default value is 0. (Added at v3.1)

<Number> opacity

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.
Known values: 0.0 - 1.0
Default value: 1.0

<Number> refreshInterval

Refresh interval of the layer in minutes. Non-zero value indicates automatic layer refresh at the specified interval. Value of 0 indicates auto refresh is not enabled. (Added at v3.7)

<Boolean> showAttribution

When true, the layer's attribution is displayed on the map. (Added at v3.1)
Known values: true | false
Default value: true

<SpatialReference> spatialReference

The spatial reference of the map service. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references.

<Boolean> suspended

When true, the layer is suspended. A layer is considered to be suspended when one of the following is true:
  • The layer is hidden.
  • The layer is not visible at the current map scale.
  • The layer is explicitly suspended by calling the Layer.suspend method.
(Added at v3.1)
Known values: true | false

<TileInfo> tileInfo

Returns TileInfo, which has information on the tiling schema.

<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. (Added at 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.

<String> url

URL to the ArcGIS Server REST resource that represents a map service. To obtain the URL, use Services Directory. An example URL for the Street Map service on ArcGIS Online is:
https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer. (Added at v1.2)

<Number> version

The version of ArcGIS Server where the map service is published. Examples are 9.3, 9.31, 10. (Added at v2.1)

<Boolean> visible

Visibility of the layer.
Known values: true | false
Default value: true

<Boolean> visibleAtMapScale

When true, the layer is visible at the current map scale. (Added at v3.1)
Known values: true | false
Method Details

attr(name, value)

Adds a new attribute or changes the value of an existing attribute on the layer's node. Removes the attribute if the value is null or undefined. (Added at v3.7)
Return type: Layer
Parameters:
<String> name Required The name of the attribute.
<String> value Required The value of the attribute. Set this value as null to remove the attribute.

getAttributionData()

Asynchronously returns custom data for the layer when available. (Added at v3.1)
Return type: Deferred

getMap()

Returns reference to the map control the layer is added to. Returns null or undefined if it is not added to a map. (Added at v3.7)
Return type: Map

getNode()

Returns the layer's DOM node. (Added at v3.7)
Return type: HTMLElement

getTileUrl(level, row, column)

Method to implement when extending TiledMapServiceLayer. For more details, see Creating custom layer types. (Added at v1.3)
Return type: String
Parameters:
<Number> level Required Requested tile's level.
<Number> row Required Requested tile's row.
<Number> column Required Requested tile's column.

hide()

Sets the visibility of the layer to "false". The layer is not removed, but it is hidden from view.

isVisibleAtScale(scale)

Returns true if the layer is visible at the given scale. (Added at v3.1)
Return type: Boolean
Parameters:
<Number> scale Required The scale at which to check if the layer is visible.

refresh()

Reloads all the tiles in the current view. (Added at v1.2)

resume()

Resumes layer drawing. (Added at v3.1)

setExclusionAreas()

Specify areas to not show tiles. See the exclusionAreas constructor option description for specifics as to how exclusionAreas work. (Added at v3.10)
Return type: Array
Sample:
var exclusionAreas = [{
  minScale: 40000,
  maxScale: 9028,
  geometry: new Extent(
    13871520.850500003,
    3910293.086000003,
    14574034.873400003,
    4686306.161399998,
    new SpatialReference(102100)
  )
}];

setInfoTemplates(infoTemplates)

Set the infoTemplates property. (Added at v3.10)
Parameters:
<Object> infoTemplates Required infoTemplates object. See the infoTemplates property for details.

setMaxScale(scale)

Set the maximum scale for the layer. (Added at v3.1)
Parameters:
<Number> scale Required The maximum scale at which the layer is visible.

setMinScale(scale)

Set the minimum scale for the layer. (Added at v3.1)
Parameters:
<Number> scale Required The minimum scale at which the layer is visible.

setOpacity(opacity)

Sets the opacity of the layer. Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency.
Parameters:
<Number> opacity Required Value from 0 to 1, where 0 is 100% transparent and 1 has no transparency. The default value is 1.
Sample:

layer.setOpacity(0.5);

setRefreshInterval(interval)

Changes the layer's refresh interval to the given value (in minutes). Non-zero value sets up automatic layer refresh at the specified interval. Value of 0 stops auto refresh. (Added at v3.7)
Return type: Layer
Parameters:
<Number> interval Required Refresh interval of the layer in minutes. Non-zero value indicates automatic layer refresh at the specified interval. Value of 0 indicates auto refresh is not enabled.

setScaleRange(minScale, maxScale)

Set the scale range for the layer. If minScale and maxScale are set to 0 then the layer will be visible at all scales. (Added at v3.1)
Parameters:
<Number> minScale Required The minimum scale at which the layer is visible.
<Number> maxScale Required The maximum scale at which the layer is visible.

setVisibility(isVisible)

Sets the visibility of the layer. When true, the layer is visible.
Parameters:
<Boolean> isVisible Required Set the visibility of the layer.

show()

Sets the visibility of the layer to "true".

suspend()

Suspends layer drawing. (Added at v3.1)
Event Details
[ On Style Events | Connect Style Event ]

error

Fires when there is a problem retrieving a layer. Should be used in favor of onError. (Added at v3.5)
Event Object Properties:
<Error> error ArcGIS Server error message returned in a JavaScript error object.

load

Fires after layer properties for the layer are successfully populated. This event must be successful before the layer can be added to the map. Should be used in favor of onLoad. (Added at v3.5)
Event Object Properties:
<Layer> layer The loaded layer.

opacity-change

Fires when the layer opacity has been changed, and returns an object with the opacity value. Should be used in favor of onOpacityChange. (Added at v3.5)
Event Object Properties:
<Number> opacity Fires when the layer opacity (transparency) changes. A number property named opacity that indicates the new opacity. Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency.

refresh-interval-change

This event is fired when the layer's refreshInterval is modified. (Added at v3.7)

resume

Fires when a layer resumes drawing. (Added at v3.6)

scale-range-change

Fires when a layer's minScale and/or maxScale is changed. (Added at v3.6)

scale-visibility-change

Fires when a layer's scale visibility changes. The scale visibility changes when a layer is initially visible and becomes invisible because the map scale does not intersect the layer's scale range or vice versa. (Added at v3.6)

suspend

Fires when a layer suspends drawing. (Added at v3.6)

update

Fires any time a layer has finished loading or updating itself. For an ArcGISTiledMapServiceLayer, the event fires when all required tiles have been retrieved and displayed. For an ArcGISDynamicMapServiceLayer or ArcGISImageServiceLayer, the event fires when the map image has been retrieved and displayed. For a GraphicsLayer, the event fires when all graphics have been redrawn after a pan or zoom. Deprecated at v2.0. Use update-start and update-end instead. (Added at v3.6)

update-end

Fires when a layer has finished updating its content. It is the responsibility of the subclass to determine when this event is fired. Should be used in favor of onUpdateEnd. (Added at v3.5)
Event Object Properties:
<Error> error Optional argument. The error object is available when an error occurs during the update.

update-start

Fires when a layer begins to update its content. It is the responsibility of the subclass to determine when this event is fired. Should be used in favor of onUpdateStart. (Added at v3.5)

visibility-change

Fires when the layer visibility has been changed, and returns an object with a Boolean visible property containing the new visibility value of the layer. Should be used in favor of onVisibilityChange. (Added at v3.5)
Event Object Properties:
<Boolean> visible Fires when the layer visibility changes. A boolean property named visible indicates whether or not the layer is visible after visibility changed.
Show Modal