Class WmsLayer

All Implemented Interfaces:
TimeAware, RemoteResource, LayerContent, Loadable

public final class WmsLayer extends ImageAdjustmentLayer implements RemoteResource, TimeAware
A layer that can visualize data from a WMS service.

Web Map Service (WMS) is an Open Geospatial Consortium (OGC) standard for delivering map images from an online service. {code WMSLayer} displays data from a web service that provides maps in the form of server-rendered images. The service may be hosted in ArcGIS Enterprise or in a third party server. This API supports WMS versions 1.1.0, 1.1.1, and 1.3.0.

Functional characteristics

A WMS service can contain multiple layers in a hierarchy. A WMS layer can be constructed directly with a URL to a service and the uniquely identifying name of the desired layer. Alternatively, a WmsService can be used to programmatically explore the available layers and allow the user to choose layers at run time.

The maps provided by a WMS service use predefined symbology defined by the server. As a result, it is not possible to apply custom renderers or to visualize feature selection. WMS layers can have multiple style options. Your app can choose from the available styles.

Some layers can be marked as opaque, which means that they cover most of the map area and are good candidates for use as a basemap.

WMS layers support identify and time. They do not support selection or query. Note that due to the nature of WMS, it is not possible to retrieve feature geometry from WMS identify results. WMS layers support custom parameters, which can be specified for the service or an individual layer.

Performance characteristics

WMS servers render map images on demand, which can require more server resources than a similar tiled service. WMS requires a service connection at all times.

Since:
100.2.0
See Also:
  • Constructor Details

    • WmsLayer

      public WmsLayer(PortalItem portalItem)
      Creates a WMS layer from a portal item.
      Parameters:
      portalItem - a portal item of type PortalItem.Type.WMS.
      Throws:
      NullPointerException - if portalItem is null
      Since:
      200.1.0
      See Also:
    • WmsLayer

      public WmsLayer(String url, Iterable<String> layerNames)
      Creates a WmsLayer with the specified URL and layer names.

      To specify a preferred WMS version, set the 'VERSION' parameter in the 'GetCapabilities' URL for the service.

      Parameters:
      url - the URL of a WMS service
      layerNames - the names of layers of the service to be included in the WmsLayer
      Throws:
      IllegalArgumentException - if url or layerNames is null or empty
      Since:
      100.2.0
    • WmsLayer

      public WmsLayer(Iterable<WmsLayerInfo> layerInfos)
      Creates a WmsLayer from the specified WmsLayerInfo objects.
      Parameters:
      layerInfos - a collection of WmsLayerInfo objects
      Throws:
      IllegalArgumentException - if layerInfos is null or empty
      Since:
      100.2.0
  • Method Details

    • setCredential

      public void setCredential(Credential credential)
      Description copied from interface: RemoteResource
      Sets a Credential 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 interface RemoteResource
      Parameters:
      credential - the Credential to be used for authentication
    • getCredential

      public Credential getCredential()
      Description copied from interface: RemoteResource
      Gets the Credential that is set on the network-enabled resource.

      Only applicable if the resource is secured.

      Specified by:
      getCredential in interface RemoteResource
      Returns:
      the Credential, or null if there is none
    • setRequestConfiguration

      public void setRequestConfiguration(RequestConfiguration requestConfiguration)
      Description copied from interface: RemoteResource
      Sets the RequestConfiguration used to modify the parameters of network requests made by this RemoteResource. If not set, the global RequestConfiguration will be used (see RequestConfiguration.getGlobalRequestConfiguration()).
      Specified by:
      setRequestConfiguration in interface RemoteResource
      Parameters:
      requestConfiguration - the RequestConfiguration used to modify network requests
    • getRequestConfiguration

      public RequestConfiguration getRequestConfiguration()
      Description copied from interface: RemoteResource
      Gets the RequestConfiguration used to modify the parameters of network requests made by this RemoteResource.
      Specified by:
      getRequestConfiguration in interface RemoteResource
      Returns:
      the RequestConfiguration used to modify network requests
    • getUri

      public String getUri()
      The WMS service endpoint URL of this WmsLayer.
      Specified by:
      getUri in interface RemoteResource
      Returns:
      the URL of the WMS service
      Since:
      100.2.0
    • getCustomParameters

      public Map<String,String> getCustomParameters()
      Gets the dictionary of custom parameters to be sent with WMS requests issued by this layer.

      These parameters are appended to GetMap and GetFeatureInfo requests. If a parameter with the same name is defined in WmsService.getCustomParameters(), then layer-specific values take precedence over service-wide values.

      Returns:
      the dictionary of custom parameters to be sent with WMS requests issued by this layer
      Since:
      100.3.0
    • getLayerNames

      public List<String> getLayerNames()
      Gets a collection of the names of the visible WMS layers.
      Returns:
      an unmodifiable list of the names of the visible WMS layers
      Since:
      100.2.0
    • getLayerInfos

      public List<WmsLayerInfo> getLayerInfos()
      Gets a list of WmsLayerInfos for the layers included in this WmsLayer.
      Returns:
      an unmodifiable list of WmsLayerInfos; this will be empty if the WmsLayer was created using the WmsLayer(String, Iterable) constructor and has not been loaded yet
      Since:
      100.2.0
    • setPreferredImageFormat

      public void setPreferredImageFormat(ArcGISMapImageLayer.ImageFormat imageFormat)
      Sets the preferred image format.
      Parameters:
      imageFormat - the preferred image format
      Throws:
      IllegalArgumentException - if imageFormat is null
      Since:
      100.2.0
    • getPreferredImageFormat

      public ArcGISMapImageLayer.ImageFormat getPreferredImageFormat()
      The preferred image format of this WmsLayer.

      If a preferred format is not specified prior to loading, then ArcGISMapImageLayer.ImageFormat.PNG is used.

      Returns:
      the preferred image format
      Since:
      100.2.0
    • getSublayers

      public ListenableList<WmsSublayer> getSublayers()
      Gets the collection of the sublayers in this WMS layer.

      This is a flat, ordered list of named sublayers.

      Returns:
      the unmodifiable collection of the sublayers in this WMS layer
      Since:
      100.2.0
    • copy

      public WmsLayer copy()
      Creates a deep copy of this WmsLayer instance.
      Returns:
      a deep copy of this WmsLayer instance, which means that copies of all fields of this layer are made including its loading state
      Since:
      100.2.0
    • getRefreshInterval

      public long getRefreshInterval()
      Gets the refresh interval in milliseconds. The refresh interval is the time between automatic data requests being sent to the server. A value of zero means the layer is never refreshed. The default value is zero.
      Returns:
      the refresh interval in milliseconds
      Since:
      100.2.1
    • setRefreshInterval

      public void setRefreshInterval(long refreshIntervalMilliseconds)
      Sets the refresh interval in milliseconds. The refresh interval is the time between automatic data requests being sent to the server. A value of zero means the layer is never refreshed. The default value is zero.
      Parameters:
      refreshIntervalMilliseconds - the refresh interval in milliseconds
      Throws:
      IllegalArgumentException - if refreshIntervalMilliseconds is less than zero
      Since:
      100.2.1
    • getVersion

      public WmsVersion getVersion()
      The version of the WMS specification used by this WmsLayer.

      This API supports the following WMS versions: 1.3.0, 1.1.1, and 1.1.0. By default this value is the latest supported WMS version.

      Returns:
      the WMS version
      Since:
      100.2.1
    • getFullTimeExtent

      public TimeExtent getFullTimeExtent()
      Description copied from interface: TimeAware
      Returns the full time extent of the object. Will be null if the object is not time aware.
      Specified by:
      getFullTimeExtent in interface TimeAware
      Returns:
      the time extent, or null if the object is not time aware
    • getTimeInterval

      public TimeValue getTimeInterval()
      Description copied from interface: TimeAware
      Returns the suggested time slider step size for this time aware object. Can be null if no time interval is suggested for this time aware object.
      Specified by:
      getTimeInterval in interface TimeAware
      Returns:
      the time interval, or null if there is no time interval
    • getTimeOffset

      public TimeValue getTimeOffset()
      Description copied from interface: TimeAware
      Returns the time offset applied to this object. The offset is subtracted from the time extent set on the owning GeoView. This allows for data from different periods of time to be compared.
      Specified by:
      getTimeOffset in interface TimeAware
      Returns:
      the time offset, or null if no offset has been set
    • isTimeFilteringEnabled

      public boolean isTimeFilteringEnabled()
      Description copied from interface: TimeAware
      Returns whether or not the object must use the time extent defined on the owning GeoView to filter its data.
      Specified by:
      isTimeFilteringEnabled in interface TimeAware
      Returns:
      true if time filtering is enabled; otherwise false
    • setIsTimeFilteringEnabled

      public void setIsTimeFilteringEnabled(boolean enabled)
      Description copied from interface: TimeAware
      Enables or disables whether the object must use the time extent defined on the owning GeoView to filter its data.
      Specified by:
      setIsTimeFilteringEnabled in interface TimeAware
      Parameters:
      enabled - true to enable time filtering; otherwise false
    • isTimeFilteringSupported

      public boolean isTimeFilteringSupported()
      Description copied from interface: TimeAware
      Returns whether or not the object supports filtering its contents by time values with the extent set on the owning GeoView.
      Specified by:
      isTimeFilteringSupported in interface TimeAware
      Returns:
      true if time filtering is supported; otherwise false
    • setTimeOffset

      public void setTimeOffset(TimeValue timeOffset)
      Description copied from interface: TimeAware
      Sets a time offset for this object. The time offset is subtracted from the time extent set on the owning GeoView. This allows for data from different periods of time to be compared. Can be null if there is no time offset.
      Specified by:
      setTimeOffset in interface TimeAware
      Parameters:
      timeOffset - the time offset, or null if there is no time offset
    • addFullTimeExtentChangedListener

      public void addFullTimeExtentChangedListener(FullTimeExtentChangedListener listener)
      Description copied from interface: TimeAware
      Adds a listener that will fire when there is a change to the full time extent.
      Specified by:
      addFullTimeExtentChangedListener in interface TimeAware
      Parameters:
      listener - the listener to add
    • removeFullTimeExtentChangedListener

      public boolean removeFullTimeExtentChangedListener(FullTimeExtentChangedListener listener)
      Description copied from interface: TimeAware
      Removes a full time extent changed listener.
      Specified by:
      removeFullTimeExtentChangedListener in interface TimeAware
      Parameters:
      listener - the listener to remove
      Returns:
      true if the listener was removed, otherwise false