Class WmtsLayer
- java.lang.Object
-
- com.esri.arcgisruntime.layers.Layer
-
- com.esri.arcgisruntime.layers.ImageAdjustmentLayer
-
- com.esri.arcgisruntime.layers.ImageTiledLayer
-
- com.esri.arcgisruntime.layers.WmtsLayer
-
- All Implemented Interfaces:
RemoteResource
,LayerContent
,Loadable
public final class WmtsLayer extends ImageTiledLayer implements RemoteResource
Displays data from a WMTS service by using pre-generated tiles.Web Map Tile Service (WMTS) is an Open GeospatialConsortium (OGC) standard for delivering geographic data via raster tiles. ArcGIS Runtime supports WMTS 1.0.0. The service may be hosted in the cloud on ArcGIS Online, on a third party server, or on-premises with ArcGIS Server.
A WMTS layer uses pre-generated tiles to create a map instead of dynamically generating map images.
Functional characteristics
The maps provided by a WMTS service use predefined symbology defined by the server. As a result, it is not possible to apply custom renderers or to visualize feature selection.
A WMTS service can contain multiple layers in a hierarchy. A WMTS layer can be constructed directly with a URL to a service and the uniquely identifying name of the desired layer. Alternatively, a WMTS service can be used to programmatically explore the available layers and allow the user to choose layers at run time.
Performance characteristics
WMTS layer consumes raster tiles that were prerendered by a server. WMTS requires fewer server resources than WMS because the images are rendered and cached ahead of time. WMTS layer requires a connection to the service at all times.
Creating a WTMS layer from URL
For some WMTS services it may be necessary to provide a direct URI to the getCapabilities resource, by appending either
/1.0.0/WMTSCapabilities.xml
or?service=wmts&request=getCapabilities&version=1.0.0
to the root WMTS URI.Example for working with WMTS layer
final WmtsLayer wmtsLayer = new WmtsLayer( "http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS?", "WorldTimeZones"); wmtsLayer.addDoneLoadingListener(() -> { if (wmtsLayer.getLoadStatus() == LoadStatus.LOADED) { // work with WMTS layer here } }); map.getOperationalLayers().add(wmtsLayer);
The layer is loaded when displayed in aMapView
or aSceneView
; if using the layer without aMapView
or aSceneView
, call theLayer.loadAsync()
method. Use the layer done loading event to determine when the layer is ready, and check the loaded status before using the layer.- Since:
- 100.1.0
- See Also:
Layer
,ImageTiledLayer
,WmtsService
,WmtsServiceInfo
,WmtsLayerInfo
,WmtsTileMatrixSet
,Layer
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.esri.arcgisruntime.layers.ImageTiledLayer
ImageTiledLayer.BufferSize, ImageTiledLayer.NoDataTileBehavior
-
-
Constructor Summary
Constructors Constructor Description WmtsLayer(WmtsLayerInfo layerInfo)
Creates an instance of WmtsLayer from aWmtsLayerInfo
.WmtsLayer(WmtsLayerInfo layerInfo, TileInfo.ImageFormat preferredImageFormat)
Creates an instance of WmtsLayer from aWmtsLayerInfo
, and a preferred image format.WmtsLayer(WmtsLayerInfo layerInfo, WmtsTileMatrixSet tileMatrixSet)
Creates an instance of WmtsLayer from aWmtsLayerInfo
, and a tile matrix set.WmtsLayer(WmtsLayerInfo layerInfo, WmtsTileMatrixSet tileMatrixSet, TileInfo.ImageFormat preferredImageFormat)
Creates an instance of WmtsLayer from aWmtsLayerInfo
, tile matrix set, and a preferred image format.WmtsLayer(java.lang.String url, java.lang.String layerId)
Creates an instance of WmtsLayer from a url and a layer ID.WmtsLayer(java.lang.String url, java.lang.String layerId, TileInfo.ImageFormat preferredImageFormat)
Creates an instance of WmtsLayer from a URL, layer ID, and a preferred image format.WmtsLayer(java.lang.String url, java.lang.String layerId, java.lang.String tileMatrixSetId)
Creates an instance of WmtsLayer from a URL, layer ID, and a tile matrix set ID.WmtsLayer(java.lang.String url, java.lang.String layerId, java.lang.String tileMatrixSetId, TileInfo.ImageFormat preferredImageFormat)
Creates an instance of WmtsLayer from a URL, layer ID, tile matrix set ID, and a preferred image format.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WmtsLayer
copy()
Creates a deep copy of this WmtsLayer instance.Credential
getCredential()
Gets theCredential
that is set on the network-enabled resource.java.util.Map<java.lang.String,java.lang.String>
getCustomParameters()
Gets aMap
containing custom parameters that are applied to all GetTile requests related to this layer.java.lang.String
getLayerId()
Gets the layer ID that was used to construct this layer.WmtsLayerInfo
getLayerInfo()
Gets the layer info.TileInfo.ImageFormat
getPreferredImageFormat()
Gets the preferred image format.RequestConfiguration
getRequestConfiguration()
Gets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
.protected byte[]
getTile(TileKey tileKey)
Gets the encoded bytes that represents a tile for the given tile key.WmtsTileMatrixSet
getTileMatrixSet()
Gets the tile matrix set.java.lang.String
getUri()
Gets the URL of the WMTS layer.void
setCredential(Credential credential)
Sets aCredential
to be used by the network-enabled resource in the event of an authentication challenge.void
setRequestConfiguration(RequestConfiguration requestConfiguration)
Sets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
.-
Methods inherited from class com.esri.arcgisruntime.layers.ImageTiledLayer
getBufferSize, getNoDataTileBehavior, getTileInfo, setBufferSize, setNoDataTileBehavior
-
Methods inherited from class com.esri.arcgisruntime.layers.ImageAdjustmentLayer
getBrightness, getContrast, getGamma, setBrightness, setContrast, setGamma
-
Methods inherited from class com.esri.arcgisruntime.layers.Layer
addDoneLoadingListener, addLoadStatusChangedListener, addVisibilityChangedListener, cancelLoad, canChangeVisibility, canShowInLegend, fetchLegendInfosAsync, getAttribution, getDescription, getFullExtent, getId, getItem, getLoadError, getLoadStatus, getMaxScale, getMinScale, getName, getOpacity, getSpatialReference, getSubLayerContents, isIdentifyEnabled, isVisible, isVisibleAtScale, loadAsync, removeDoneLoadingListener, removeLoadStatusChangedListener, removeVisibilityChangedListener, retryLoadAsync, setCanShowInLegend, setDescription, setId, setMaxScale, setMinScale, setName, setOpacity, setVisible
-
-
-
-
Constructor Detail
-
WmtsLayer
public WmtsLayer(java.lang.String url, java.lang.String layerId)
Creates an instance of WmtsLayer from a url and a layer ID.- Parameters:
url
- the WMTS layer URLlayerId
- layer ID- Throws:
java.lang.IllegalArgumentException
- if url is null or emptyjava.lang.IllegalArgumentException
- if layerId is null or empty- Since:
- 100.1.0
-
WmtsLayer
public WmtsLayer(java.lang.String url, java.lang.String layerId, TileInfo.ImageFormat preferredImageFormat)
Creates an instance of WmtsLayer from a URL, layer ID, and a preferred image format.- Parameters:
url
- the WMTS layer URLlayerId
- layer IDpreferredImageFormat
- preferred image format- Throws:
java.lang.IllegalArgumentException
- if url is null or emptyjava.lang.IllegalArgumentException
- if layerId is null or emptyjava.lang.IllegalArgumentException
- if preferredImageFormat is null- Since:
- 100.1.0
-
WmtsLayer
public WmtsLayer(java.lang.String url, java.lang.String layerId, java.lang.String tileMatrixSetId)
Creates an instance of WmtsLayer from a URL, layer ID, and a tile matrix set ID.- Parameters:
url
- the WMTS layer URLlayerId
- layer IDtileMatrixSetId
- tile matrix set ID- Throws:
java.lang.IllegalArgumentException
- if url is null or emptyjava.lang.IllegalArgumentException
- if layerId is null or emptyjava.lang.IllegalArgumentException
- if tileMatrixSetId is null or empty- Since:
- 100.1.0
-
WmtsLayer
public WmtsLayer(java.lang.String url, java.lang.String layerId, java.lang.String tileMatrixSetId, TileInfo.ImageFormat preferredImageFormat)
Creates an instance of WmtsLayer from a URL, layer ID, tile matrix set ID, and a preferred image format.- Parameters:
url
- the WMTS layer URLlayerId
- layer IDtileMatrixSetId
- tile matrix set IDpreferredImageFormat
- preferred image format- Throws:
java.lang.IllegalArgumentException
- if url is null or emptyjava.lang.IllegalArgumentException
- if layerId is null or emptyjava.lang.IllegalArgumentException
- if tileMatrixSetId is null or emptyjava.lang.IllegalArgumentException
- if preferredImageFormat is null- Since:
- 100.1.0
-
WmtsLayer
public WmtsLayer(WmtsLayerInfo layerInfo)
Creates an instance of WmtsLayer from aWmtsLayerInfo
.- Parameters:
layerInfo
- layer info- Throws:
java.lang.IllegalArgumentException
- if layerInfo is null- Since:
- 100.1.0
-
WmtsLayer
public WmtsLayer(WmtsLayerInfo layerInfo, TileInfo.ImageFormat preferredImageFormat)
Creates an instance of WmtsLayer from aWmtsLayerInfo
, and a preferred image format.- Parameters:
layerInfo
- layer infopreferredImageFormat
- preferred image format- Throws:
java.lang.IllegalArgumentException
- if layerInfo is nulljava.lang.IllegalArgumentException
- if preferredImageFormat is null- Since:
- 100.1.0
-
WmtsLayer
public WmtsLayer(WmtsLayerInfo layerInfo, WmtsTileMatrixSet tileMatrixSet)
Creates an instance of WmtsLayer from aWmtsLayerInfo
, and a tile matrix set.- Parameters:
layerInfo
- layer infotileMatrixSet
- tile matrix set- Throws:
java.lang.IllegalArgumentException
- if layerInfo is nulljava.lang.IllegalArgumentException
- if tileMatrixSet is null- Since:
- 100.1.0
-
WmtsLayer
public WmtsLayer(WmtsLayerInfo layerInfo, WmtsTileMatrixSet tileMatrixSet, TileInfo.ImageFormat preferredImageFormat)
Creates an instance of WmtsLayer from aWmtsLayerInfo
, tile matrix set, and a preferred image format.- Parameters:
layerInfo
- layer infotileMatrixSet
- tile matrix setpreferredImageFormat
- preferred image format- Throws:
java.lang.IllegalArgumentException
- if layerInfo is nulljava.lang.IllegalArgumentException
- if tileMatrixSet is nulljava.lang.IllegalArgumentException
- if preferredImageFormat is null- Since:
- 100.1.0
-
-
Method Detail
-
copy
public WmtsLayer copy()
Creates a deep copy of this WmtsLayer instance.- Returns:
- a deep copy of this WmtsLayer instance, which means that copies of all fields of this layer are made including its loading state
- Since:
- 100.1.0
-
getPreferredImageFormat
public TileInfo.ImageFormat getPreferredImageFormat()
Gets the preferred image format.Note that this will return the value you specified in the constructor, not necessarily what the service returned.
- Returns:
- the preferred image format
- Since:
- 100.1.0
-
getLayerInfo
public WmtsLayerInfo getLayerInfo()
Gets the layer info.- Returns:
- the layer info
- Since:
- 100.1.0
-
getLayerId
public java.lang.String getLayerId()
Gets the layer ID that was used to construct this layer.- Returns:
- the layer ID that was used to construct this layer
- Since:
- 100.1.0
-
getTileMatrixSet
public WmtsTileMatrixSet getTileMatrixSet()
Gets the tile matrix set.- Returns:
- the tile matrix set
- Since:
- 100.1.0
-
getCustomParameters
public java.util.Map<java.lang.String,java.lang.String> getCustomParameters()
Gets aMap
containing custom parameters that are applied to all GetTile requests related to this layer. Modify this Map to change the parameters that are used. If a parameter with the same name is defined in the service's custom parameters, then layer-specific values take precedence over service-wide values.- Returns:
- a modifiable Map; the keys are parameters names and the values are parameters values
- Since:
- 100.6.0
-
setCredential
public void setCredential(Credential credential)
Description copied from interface:RemoteResource
Sets aCredential
to be used by the network-enabled resource in the event of an authentication challenge. The default credential is null.Only applicable if the resource is secured.
- Specified by:
setCredential
in interfaceRemoteResource
- Parameters:
credential
- the Credential to be used for authentication
-
getCredential
public Credential getCredential()
Description copied from interface:RemoteResource
Gets theCredential
that is set on the network-enabled resource.Only applicable if the resource is secured.
- Specified by:
getCredential
in interfaceRemoteResource
- Returns:
- the Credential, or null if there is none
-
setRequestConfiguration
public void setRequestConfiguration(RequestConfiguration requestConfiguration)
Description copied from interface:RemoteResource
Sets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
. If not set, the globalRequestConfiguration
will be used (seeRequestConfiguration.getGlobalRequestConfiguration()
).- Specified by:
setRequestConfiguration
in interfaceRemoteResource
- Parameters:
requestConfiguration
- the RequestConfiguration used to modify network requests
-
getRequestConfiguration
public RequestConfiguration getRequestConfiguration()
Description copied from interface:RemoteResource
Gets theRequestConfiguration
used to modify the parameters of network requests made by thisRemoteResource
.- Specified by:
getRequestConfiguration
in interfaceRemoteResource
- Returns:
- the
RequestConfiguration
used to modify network requests
-
getUri
public java.lang.String getUri()
Gets the URL of the WMTS layer.- Specified by:
getUri
in interfaceRemoteResource
- Returns:
- the URL of the WMTS layer
- Since:
- 100.1.0
-
getTile
protected byte[] getTile(TileKey tileKey)
Description copied from class:ImageTiledLayer
Gets the encoded bytes that represents a tile for the given tile key. The encoding must matchTileInfo
specified in the constructorImageTiledLayer(TileInfo, Envelope)
.- Specified by:
getTile
in classImageTiledLayer
- Parameters:
tileKey
- key for the expected tile- Returns:
- the encoded bytes that represent the tile for the given tile key
-
-