require(["esri/layers/WMTSLayer"], function(WMTSLayer) { /* code goes here */ });
Description
(Added at v2.4)
The WMTSLayer class is used to create a layer based on an OGC Web Map Tile Service layer.
Samples
Search for
samples that use this class.
Class hierarchy
esri/layers/Layer
|_esri/layers/TiledMapServiceLayer
|_esri/layers/WMTSLayer
Constructors
Properties
Methods
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
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-change | | This event is fired when the layer's refreshInterval is modified. |
resume | | Fires when a layer resumes drawing. |
scale-range-change | | Fires when a layer's minScale and/or maxScale is changed. |
scale-visibility-change | | Fires when a layer's scale visibility changes. |
suspend | | Fires when a layer suspends drawing. |
update | | Fires any time a layer has finished loading or updating itself. |
update-end | {
error: <Error >
} | Fires when a layer has finished updating its content. |
update-start | | Fires 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
Creates a new WMTSLayer object.
Parameters:
<String > url |
Required |
URL for the WMTS endpoint. |
<Object > options |
Optional |
Optional parameters. See options list. |
options
properties:
<Object > customLayerParameters |
Optional |
The customLayerParameters object used for the WMTS Layer. NOTE: If this is also set within the constructor's resourceInfo , the parameters within the resourceInfo take precedence. |
<Object > customParameters |
Optional |
The customParameters object used for the WMTS Layer. NOTE: If this is also set within the constructor's resourceInfo , the parameters within the resourceInfo take precedence. |
<WMTSLayerInfo > layerInfo |
Optional |
A WMTSLayerInfo object that when ResourceInfo options are not specified the map will display the first layer in the WMTS capabilities that matches the properties specified by WMTSLayerInfo. For example, if the WMTSLayerInfo specifies an identifier but does not specify a tileMatrixSet the first layer in the service that has the same id will be used. |
<Boolean > resampling |
Optional |
When true, tile resampling is enabled. Default value is false. |
<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. |
<Object > resourceInfo |
Optional |
An optional resource info object. The default behavior of a WMTSLayer is to execute a WMTS GetCapabilities request, which requires using a proxy page. If resourceInfo is specified a GetCapabilities request is not executed and no proxy page is required. The resourceInfo object has the following parameters:
<String>
version
|
Version of the WMTS service.
|
<String>
tileUrl
|
The URL for the get tile request, required if it differs from the WMTS service endpoint.
|
<Object[]>
layerInfos
|
An array of WMTSLayerInfo objects. The tileInfo, fullExtent, InitialExtent, identifier, tileMatrixSet, format and style properties must be defined all others are optional.
|
<String>
copyright
|
The copyright of the WMTS service.
|
var resourceInfo = {
version: "1.0.0",
layerInfos: [layerInfo1, layerInfo2],
copyright: "open layer"
};
|
<String > serviceMode |
Optional |
Specify the service type. Valid values are "KVP" or "RESTful". If the specified mode does not match the service the WMTS layer will not be created. The default value is "RESTful". |
Object Specifications: <resourceInfo
>
<Object > customLayerParameters |
Required |
Use this to append different custom parameters to a WMTS tile request.
"customLayerParameters" : {
"QUALITY": "90"
}
The custom parameters are applied to GetTile
NOTE: customLayerParameters can be part of resourceInfo or outside of it in the WMTSLayer's constructor. If it is set in resourceInfo and also directly as customLayerParameters in the constructor, the one in resourceInfo takes precedence. |
<Object > customParameters |
Required |
Use this to append custom parameters to all WMTS requests. If an access key is required, the key can be configured as a custom parameter.
"customParameters" : {"key": "1R-ADNF-6NCD"}
The custom parameters are applied to GetCapabilities and GetTile
NOTE: customParameters can be part of resourceInfo or outside of it in the WMTSLayer's constructor. If it is set in resourceInfo and also directly as customParameters in the constructor, the one in resourceInfo takes precedence. |
Sample:
require([
"esri/layers/WMTSLayerInfo", "esri/layers/WMTSLayer", ...
], function(WMTSLayerInfo, WMTSLayer, ... ) {
var layerInfo = new WMTSLayerInfo({
identifier: "world",
tileMatrixSet: "EPSG:4326",
format: "gif"
});
var options = {
serviceMode: "KVP",
layerInfo: layerInfo
};
var wmtsLayer = new WMTSLayer("http://v2.suite.opengeo.org/geoserver/gwc/service/wmts", options);
...
});
Property Details
class attribute of the layer's node.
(Added at v3.7)
Copyright information for the service. This information is only available if specified in the capabilities file or the resource info object.
Use this to append different custom parameters to a WMTS tile request. The custom parameters are applied to GetTile
.
NOTE: customLayerParameters
can be part of resourceInfo
or outside of it in the WMTSLayer's constructor. If both are set in resourceInfo
and also directly as customLayerParameters
in the constructor, the one in resourceInfo
takes precedence. (Added at v3.18)
Sample:
"customLayerParameters" : {
"QUALITY": "90"
}
Use this to append custom parameters to all WMTS requests. If an access key is required, the key can be configured as a custom parameter.
The custom parameters are applied to GetCapabilities
and GetTile
.
NOTE: customParameters
can be part of resourceInfo
or outside of it in the WMTSLayer's constructor. If it is set in resourceInfo
and also directly as customParameters
in the constructor, the one in resourceInfo
takes precedence. (Added at v3.18)
Sample:
"customParameters" : {"key": "1R-ADNF-6NCD"}
The description of the active layer if specified in the capabilties file or the resource info.
The full extent of the active layer.
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);
}
}
The initial extent of the active layer.
An array of WMTSLayerInfo objects.
Set if the layer failed to load. (Added at v3.9)
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
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. (Added at v3.1)
Default value: 0
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. (Added at v3.1)
Default value: 0
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
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)
The service mode for the WMTS layer.
Known values: KVP | RESTful
When true, the layer's attribution is displayed on the map. (Added at v3.1)
Known values: true | false
Default value: true
The spatial reference for the WMTS service.
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
The tile info for the active layer.
Title of the WMTS service.
Version of the WMTS service.
Visibility of the layer.
Known values: true | false
Default value: true
When true, the layer is visible at the current map scale. (Added at v3.1)
Known values: true | false
Method Details
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)
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. |
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)
Returns the layer's DOM node. (Added at v3.7)
Parameters:
<Number > level |
Required |
Requested tile's level. |
<Number > row |
Required |
Requested tile's row. |
<Number > column |
Required |
Requested tile's column. |
Sets the visibility of the layer to "false". The layer is not removed, but it is hidden from view.
Returns true if the layer is visible at the given scale. (Added at v3.1)
Parameters:
<Number > scale |
Required |
The scale at which to check if the layer is visible. |
Reloads all the tiles in the current view. (Added at v1.2)
Resumes layer drawing. (Added at v3.1)
Set the active layer for the WMTS service. The layer must be in the same spatial reference as the current active layer.
Parameters:
<WMTSLayerInfo > WMTSLayerInfo |
Required |
The WMTSLayerInfo for the layer to make active. |
Sample:
require([
"esri/layers/WMTSLayerInfo", ...
], function(WMTSLayerInfo, ... ) {
var layerInfo = new WMTSLayerInfo({identifier: layerId});
wmtsLayer.setActiveLayer(layerInfo);
...
});
Sets the custom parameters used on the WMTS layer. If
customParameters is used, it applies on the
GetCapabilities
and
GetTile
methods, whereas
customLayerParameters is used only for map requests. If both are set,
customLayerParameters
takes precedence.
NOTE: This will update the properties and refresh the layer. In addition, if one of the inputs is empty it will overwrite it as not being set.
(Added at v3.18)
Specify areas to not show tiles. See the exclusionAreas constructor option description for specifics as to how exclusionAreas work. (Added at v3.10)
Sample: var exclusionAreas = [{
minScale: 40000,
maxScale: 9028,
geometry: new Extent(
13871520.850500003,
3910293.086000003,
14574034.873400003,
4686306.161399998,
new SpatialReference(102100)
)
}];
Set the maximum scale for the layer. (Added at v3.1)
Parameters:
<Number > scale |
Required |
The maximum scale at which the layer is visible. |
Set the minimum scale for the layer. (Added at v3.1)
Parameters:
<Number > scale |
Required |
The minimum scale at which the layer is visible. |
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);
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)
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. |
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. |
Sets the visibility of the layer. When true, the layer is visible.
Parameters:
<Boolean > isVisible |
Required |
Set the visibility of the layer. |
Sets the visibility of the layer to "true".
Suspends layer drawing. (Added at v3.1)
Event Details
[ On Style Events | Connect Style Event ]
Fires when there is a problem retrieving a layer. Should be used in favor of onError. (Added at v3.5)
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. |
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. |
This event is fired when the layer's refreshInterval
is modified. (Added at v3.7)
Fires when a layer resumes drawing. Should be used in favor of onResume. (Added at v3.5)
Fires when a layer's minScale and/or maxScale is changed. Should be used in favor of onScaleRangeChange. (Added at v3.5)
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. Should be used in favor of onScaleVisibilityChange. (Added at v3.5)
Fires when a layer suspends drawing. Should be used in favor of onSuspend. (Added at v3.5)
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. |
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)
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. |
Fires when there is a problem retrieving a layer. (Added at v1.3)
Fires after layer properties for the layer are successfully populated. This event must be successful before the layer can be added to the map.
In Internet Explorer, due to resource caching, the onLoad event is fired as soon as the layer is constructed. Consequently you should check whether the layer's loaded property is true before registering a listener for the onLoad event:
Event Object Properties:
<Layer > layer |
The loaded layer. |
Sample: function init() {
//setting initial extent in constructor
var map = new esri.Map("mapDiv", { extent: new esri.geometry.Extent(...) });
//or use set extent method
var map = new esri.Map("mapDiv");
map.setExtent(new esri.geometry.Extent(...));
//add first layer
map.addLayer(...);
}
Fires when the layer opacity has been changed, and returns the opacity value.
Event Object Properties:
<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. |
This event is fired when the layer's refreshInterval
is modified. (Added at v3.7)
Fires when a layer resumes drawing. (Added at v3.1)
Fires when a layer's minScale and/or maxScale is changed. (Added at v3.1)
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.1)
Fires when a layer suspends drawing. (Added at v3.1)
Fires when a layer has finished updating its content. It is the responsibility of the subclass to determine when this event is fired.
Event Object Properties:
<Error > error |
Optional argument. The error object is available when an error occurs during the update. |
Sample: dojo.connect(layer, "onUpdateEnd", layerUpdateCompleted);
function layerUpdateCompleted(error) {
if (error) {
console.log("Update completed with error: ", error);
}
else {
console.log("Update completed");
}
}
Fires when a layer begins to update its content. It is the responsibility of the subclass to determine when this event is fired.
Sample:
dojo.connect(layer, "onUpdateStart", layerUpdateStarted);
function layerUpdateStarted() {
console.log("Update started...");
}
Fires when the layer visibility has been changed, and returns the new visibility.
Event Object Properties:
<Boolean > visbility |
Determines whether the layer is visible on the map. |