public class

WMSLayer

extends DynamicLayer
java.lang.Object
   ↳ com.esri.android.map.Layer
     ↳ com.esri.android.map.DynamicLayer
       ↳ com.esri.android.map.ogc.WMSLayer

Class Overview

A Web Map Service (WMS) layer is based on data from an Open Geospatial Consortium (OGC), WMS server. OGC WMS is an OpenGIS standard specification for interactive mapping based on requesting map images from a server over the Internet. The WMS layer allows you to access these services over the Internet and add their content to a map. The layer supports only WMS versions 1.3, 1.1.1, and 1.1. To instantiate a WMS layer, provide a URL to the WMS service, not the map service's REST endpoint. This is usually of the form:

   http://[SERVER:PORT]/[INSTANCE]/services/[SERVICE]/MapServer/WMSServer
 
The URL's structure depends on the server type. If you are consuming WMS services from servers other than ArcGIS, refer to the corresponding documentation for the URL structure.
   String wmsURL = "http://[SERVER:PORT]/[INSTANCE]/services/[SERVICE]/MapServer/WMSServer";
   WMSLayer wmsLayer = new WMSLayer(wmsURL);
   mMapView.addLayer(wmsLayer);
 
The layers default spatial reference and extent come from its layer hierarchy. You can specify a spatial reference using an overloaded constructor.
   // use a spatial reference defined by sr
   WMSLayer wmsLayer = new WMSLayer(wmsURL, sr);
   mMapView.addLayer(wmsLayer);
 
You can alter the visibility of the sub-layers of the WMS layer using the getter/setter methods. For example, you can specify which layers in the service should be visible by providing a string array of layer names to the setVisibleLayer() method.
   String[] visibleLayers = {"ushigh", "counties"};
   wmsLayer.setVisibleLayer(visibleLayers);
 
You can get all the information provided by the WMS service including all sub-layers. Calling the getLayers() method returns a WMSLayerInfo class that represents all available layers.
   WMSLayerInfo[] wmsLayerInfo = wmsLayer.getLayers();
 
This class searches for its default spatial reference and extent from root to bottom in its layer hierarchy. It allows users to specify the default spatial references in the constructor too if users want to do that.

Summary

[Expand]
Inherited Fields
From class com.esri.android.map.DynamicLayer
From class com.esri.android.map.Layer
Public Constructors
WMSLayer(String url)
This constructor is used if you're instantiating the WMSLayer using a URL.
WMSLayer(String url, String[] visibleLayers)
This constructor is used if you're instantiating the WMSLayer using a URL and visible layer names.
WMSLayer(String url, SpatialReference sr)
This constructor is used if you're instantiating the WMSLayer using a URL and default spatial reference.
WMSLayer(String url, boolean checkSupportedSRs)
This constructor is used if you're instantiating the WMSLayer using a URL and checkSupportedSRs flag.
WMSLayer(String url, SpatialReference sr, boolean checkSupportedSRs, String[] visibleLayers, UserCredentials credentials, boolean initLayer)
This constructor is used if you're instantiating the WMSLayer using a URL, default spatial reference, checkSupportedSRs flag, visible layer names, user credential and initLayer flag.
Public Methods
String getImageFormat()
Returns the image format.
WMSLayerInfo[] getLayers()
Gets all layer information available in the service.
String[] getSupportedImageFormats()
Gets the supported image formats.
SpatialReference[] getSupportedSpatialReferences()
Gets supported spatial references.
String getVersion()
Gets the WMS service's version.
String[] getVisibleLayers()
Gets visible layer names.
boolean isTransparent()
True if the image background is transparent.
void setImageFormat(String format)
Sets the image format as a string('image/png', etc.).
void setTransparent(boolean transparent)
Sets the image background to be transparent or not.
void setVisibleLayer(String[] layerNames)
Sets visible layers by specifying the layer names.
Protected Methods
byte[] getImage(int width, int height, Envelope extent)
void initLayer()
Initializes the layer.
void updateSpatialReferenceStatus(int SRStatus)
The callback method is invoked when the layer is added to map.
[Expand]
Inherited Methods
From class com.esri.android.map.DynamicLayer
From class com.esri.android.map.Layer
From class java.lang.Object
From interface com.esri.android.map.popup.PopupLayer

Public Constructors

public WMSLayer (String url)

This constructor is used if you're instantiating the WMSLayer using a URL.

Parameters
url String: URL string to the WMS layer.

public WMSLayer (String url, String[] visibleLayers)

This constructor is used if you're instantiating the WMSLayer using a URL and visible layer names.

Parameters
url String: URL string to the WMS layer.
visibleLayers String: names of sub-layers to be included in the image rendered(EPSG:3857, etc.).

public WMSLayer (String url, SpatialReference sr)

This constructor is used if you're instantiating the WMSLayer using a URL and default spatial reference. A WMSLayer may support several spatial references. Users can specify a default spatial reference instead of asking WMSLayer to choose one automatically.

Parameters
url String: URL string to the WMS layer.
sr SpatialReference: default spatial reference of the layer.

public WMSLayer (String url, boolean checkSupportedSRs)

This constructor is used if you're instantiating the WMSLayer using a URL and checkSupportedSRs flag. If checkSupportedSRs is false, it assumes that WMS layer can be projected to any spatial reference and it will not check if map's spatial reference is in the supported spatial reference list of the WMS layer. Users can set this flag to false if some spatial reference is supported by WMS service but not declared in its capability response.

Parameters
url String: URL string to the WMS layer.
checkSupportedSRs boolean: a flag which indicate to check if map's spatial reference is in the WMSLayer's supported spatial reference list or not.

public WMSLayer (String url, SpatialReference sr, boolean checkSupportedSRs, String[] visibleLayers, UserCredentials credentials, boolean initLayer)

This constructor is used if you're instantiating the WMSLayer using a URL, default spatial reference, checkSupportedSRs flag, visible layer names, user credential and initLayer flag.

Parameters
url String: URL string to the WMS layer.
sr SpatialReference: default spatial reference.
checkSupportedSRs boolean: true if map's spatial reference is checked against spatial reference list supported by the WMS service when layer is added into map.
visibleLayers String: names of sub-layers to be included in the image rendered.
credentials UserCredentials: user credential
initLayer boolean: true if layer initialization happens immediately.

Public Methods

public String getImageFormat ()

Returns the image format. Default is 'image/png'.

Returns
String image format in String.

public WMSLayerInfo[] getLayers ()

Gets all layer information available in the service.

Returns
WMSLayerInfo[] an array of WMSLayerInfo objects.

public String[] getSupportedImageFormats ()

Gets the supported image formats.

Returns
String[] supported image formats in String array.

public SpatialReference[] getSupportedSpatialReferences ()

Gets supported spatial references.

Returns
SpatialReference[] spatial references in array.

public String getVersion ()

Gets the WMS service's version.

Returns
String WMS service version in String.

public String[] getVisibleLayers ()

Gets visible layer names. If not set, all the layers are visible and a null is returned.

Returns
String[] visible layer name array.

public boolean isTransparent ()

True if the image background is transparent. Please ensure that the WMS service supports this property. Default is true.

Returns
boolean true if image background is transparent.

public void setImageFormat (String format)

Sets the image format as a string('image/png', etc.). Please ensure that the WMS service supports the requested image format.

Parameters
format String: image format in string.

public void setTransparent (boolean transparent)

Sets the image background to be transparent or not. Please ensure that the WMS service supports this property.

Parameters
transparent boolean: true if image background is set to transparent.

public void setVisibleLayer (String[] layerNames)

Sets visible layers by specifying the layer names.

Parameters
layerNames String: visible ayer name array.

Protected Methods

protected byte[] getImage (int width, int height, Envelope extent)

Parameters
width int
height int
extent Envelope
Returns
byte[]
Throws
Exception

protected void initLayer ()

Initializes the layer. The implementation should submit the OnStatusChangedListener.STATUS event accordingly.

protected void updateSpatialReferenceStatus (int SRStatus)

The callback method is invoked when the layer is added to map. 0 - Spatial Reference Invalid 1 - Spatial Reference NotNeeded 2 - Spatial Reference Projected 3 - Spatial Reference Good, -1 -layer loading failed (security etc. reasons).

Parameters
SRStatus int: an integer indicating the spatial reference status of layer