WMS Layer

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. The WMS layer is represented by the class WMSLayer class and extends DynamicLayer.

Instantiating a WMS Layer

To instantiate a WMSLayer, you need to 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 structure of the URL would depend on the type of server. Hence, if you are consuming WMS services from servers other than ArcGIS, refer to the corresponding documentation for the URL structure.

String wmsURL = "http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StateCityHighway_USA/MapServer/WMSServer";
WMSLayer wmsLayer = new WMSLayer(wmsURL);
mMapView.addLayer(wmsLayer);

Configuring WMS Layers

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);

Get Layer Information

You can get all the information provided by the WMS service including all sublayers. Calling the getLayers() method will return a WMSLayerInfo class which represents all available layers.

WMSLayerInfo[] wmsLayerInfo = wmsLayer.getLayers();
1/24/2013