Class: WMSLayer

Description

Class added v2.1
dojo.require("esri.layers.WMSLayer");

A layer for OGC Web Map Services (WMS). If the first layer added to the map is a WMS layer, the map will use the spatial reference of this layer. The default behavior of a WMSLayer is to execute a WMS GetCapabilities request, which requires using a proxy page. See the Using the proxy page help topic for more details. An alternate approach is to pass a resourceInfo object into the constructor which does not require a GetCapabilities request. Note:The WMSLayer does not support using Styled Layer Descriptor (SLD) documents.

Samples

Search for samples that use this class.  

Class hierarchy

esri.layers.Layer
  |_ esri.layers.DynamicMapServiceLayer
        |_ esri.layers.WMSLayer

Constructor

Constructor Description
esri.layers.WMSLayer(url, options?) Creates a new WMSLayer object.

Properties

Property Type Description
copyright String Copyright of the WMS service. This is the value of the AccessConstraints capabilities property.
description String Description of the WMS service. This is the value of the Abstract capabilities property.
extent Extent Extent of the WMS service.
getMapUrl String The URL for the WMS GetMap call.
imageFormat String The map image format.
layerInfos WMSLayerInfo[] List of layers in the WMS service.
maxHeight Number Maximum height in pixels the WMS service supports.
maxWidth Number Maximum width in pixels the WMS service supports.
spatialReference SpatialReference Spatial reference of the WMS service.
title String Title of the WMS service.
version String Version of the WMS service. Supported versions are: 1.1.0,1.1.1 and 1.3.0.

Methods

Method Return Value Description
setImageFormat(format) none Set the map image format, valid values are "png","jpg","pdf","bmp","gif" and "svg".
setImageTransparency(transparency) none Specify whether the background image is transparent. Only valid if the WMS service supports transparency.
setVisibleLayers(layers) none Specify a list of layer names to updates the visible layers.
Constructor Detail

esri.layers.WMSLayer(url, options?)

Creates a new WMSLayer object.
Parameters:
<String> url Required URL to the OGC Web Map Service. An example is http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer.
<Object> options Optional Optional parameters. See options list.
Options:
<String> format Specify the map image format, valid options are png,jpg,bmp,gif,svg.
<Object> resourceInfo

An optional resource info object. The default behavior of a WMSLayer is to execute a WMS 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:

Extent extent Extent of the WMS service. The extent must be specified in the spatial reference of the WMS service. Required.
WMSLayerInfo layerInfos An array of WMSLayerInfo, each WMSLayerInfo object must have the name property set. Required.
<String> version Version of the WMS service. The default value is "1.3.0". Supported versions are: "1.1.0","1.1.1" and "1.3.0". Optional.
<Number> maxWidth The maximum width, in pixels, of the WMS service. Optional.
<Number> maxHeight The maximum height, in pixels, of the WMS service. Optional.
<String[]> getMapUrl The URL for the GetMap request, required if the URL for GetCapabilities is different than the URL for GetMap.
<String> title The title of the WMS service. Optional.
<String> description The description of the WMS service. Optional.
<String> copyright The copyright of the WMS service. Optional.
var layer1 = new esri.layers.WMSLayerInfo({name:"1",title:"Rivers"});
var layer2 = new esri.layers.WMSLayerInfo({name:"2",title:"Cities"});

var resourceInfo = {
  extent: new esri.geometry.Extent(-126.40869140625,31.025390625,-109.66552734375,41.5283203125,{wkid: 4326}),
  layerInfos: [layer1,layer2]
}; 
<Boolean> transparent If the WMS service supports transparency, specify whether the image background is transparent.
<String[]> visibleLayers A list of layer names that represent the layers to include in the exported map. By default no layers are visible. The order of layers in the list defines the order the layers will display in the map.
Code snippets:

This snippet requires setting up a proxy page

var wmsLayer = new esri.layers.WMSLayer(wmsURL); 

This snippet specifies the resourceInfo option which does not require proxy page.

var wmsLayer = new esri.layers.WMSLayer(wmsURL,
  {resourceInfo: resourceInfo,
  visibleLayers: ['1','2']
  }
); 
Properties Detail

<String> copyright

Copyright of the WMS service. This is the value of the AccessConstraints capabilities property.

<String> description

Description of the WMS service. This is the value of the Abstract capabilities property.

<Extent> extent

Extent of the WMS service.

<String> getMapUrl

The URL for the WMS GetMap call.

<String> imageFormat

The map image format.

<WMSLayerInfo[]> layerInfos

List of layers in the WMS service.
Code snippets:
dojo.forEach(wmsLayer.layerInfos, function(layerInfo) {
  console.log(layerInfo.title);
});

<Number> maxHeight

Maximum height in pixels the WMS service supports.

<Number> maxWidth

Maximum width in pixels the WMS service supports.

<SpatialReference> spatialReference

Spatial reference of the WMS service.

<String> title

Title of the WMS service.

<String> version

Version of the WMS service. Supported versions are: 1.1.0,1.1.1 and 1.3.0.
Methods Detail

setImageFormat(format)

Set the map image format, valid values are "png","jpg","pdf","bmp","gif" and "svg".
Return value: none
Input Parameters:
<String> format Required The image format.
Code snippets:
wmsLayer.setImageFormat("jpg");

setImageTransparency(transparency)

Specify whether the background image is transparent. Only valid if the WMS service supports transparency.
Return value: none
Input Parameters:
<Boolean> transparency Required When true the background image is transparent.
Code snippets:
wmsLayer.setImageTransparency(true);

setVisibleLayers(layers)

Specify a list of layer names to updates the visible layers.
Return value: none
Input Parameters:
<String[]> layers Required An array of layer ids.
Code snippets:
wmsLayer.setVisibleLayers(["0","1"]);