Skip To Content

WMS layer

In this topic

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 online resource of each operation supported by a compliant WMS server is an HTTP uniform resource locator (URL), so a WMS service can be considered as a Representational State Transfer (REST) service. Unlike a standard web service, a SOAP client is not necessary for consuming a WMS service. You can get a WMS service's service level metadata, a map image, or attribute values of a feature by sending a URL request to the server and viewing the corresponding responses in the browser either as an XML document or an image.

The WMS layer is represented by the class AGSWMSLayer. This class is a subclass of AGSDynamicLayer.

Instantiating a WMS layer

To instantiate an AGSWMSLayer, you need to provide a URL to the WMS service, not the map service's REST endpoint. This is usually of the form:


For example, if you have a folder Japan containing the map service Tokyo running on myServer with the default instance arcgis, the URL of your WMS service would look like this:



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.

//Instantiate the layer and add it to the mapView.
NSURL* url = [NSURL URLWithString: @""];  
AGSWMSLayer* wmsLayer = [[AGSWMSLayer alloc] initWithURL:url];
[mapview addMapLayer:wmsLayer withName:@"Highways"];

Verifying the layer was loaded

When the layer is ready, its loaded property will be enabled. You can then safely access its properties. The following code shows you how to determine if the layer has loaded:

  NSLog(@"Initial Envelope : %@", layer.initialEnvelope);  

Configuring WMS layers

You can change the visibility of the sublayers of the WMS layer by modifying the visibleLayers property.

//only display US highways and states sublayers
layer.visibleLayers = [NSArray arrayWithObjects:@"ushigh", @"states", nil];

Unsupported coordinate systems

There might be situations when the spatial reference that you are requesting the WMS Layer may be unsupported by the WMS Service. In this case, the map view does not draw the WMS map images. If you want to handle such situations, you can attach a Key-Value Observer (KVO) to theerror property of the layer.

#pragma mark - Set KVO To Check Layer Drawing Errors

 [layer addObserver:self forKeyPath:@"error" options:0 context:nil]; 

//This method is invoked by KVO when the error property is assigned a new value
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
	AGSLayer* layer = (AGSLayer*)object;
 NSLog(@"Layer Drawing Error: %@", layer.error];