Filtering features using the layerDefs parameter in WMS requests
In this topic
The WMS specification lacks a filtering mechanism where you can append a query string or where clause in a GetMap request. Although the filters can be applied using the rules in the SLD, you will have to recreate the symbologies part in the SLD at the same time.
Alternatively, ArcGIS Server implements a vendor-specific parameter called layerDefs for both GetMap and GetFeatureInfo WMS operations. This provides a more lightweight way for the client to filter the features of individual layers in the exported map by specifying definition expressions for those layers.
The layerDefs parameter is derived from the ArcGIS Server map service layerDefs parameter. For more information about this parameter, see the ArcGIS REST API documentation.
Using layerDefs in a request
The following are some examples of how to use the layerDefs parameter in GetMap and GetFeatureInfo requests.
Note:
Keep in mind that filter expressions in the layerDefs parameter are mutually exclusive of those defined in the SLD and/or SLD_BODY. When both are present in a GetMap or GetFeatureInfo request, layerDefs has a lower priority and will be ignored.
GetMap
Filter the country layer by displaying only those countries that have a population greater than one million: layerDefs={"country":"POP_CNTRY>100000000"}.
Sample request:
http://gisserver.domain.com:6080/arcgis/services/MyMapService/MapServer/WmsServer?VERSION=1.3.0&REQUEST=GetMap&CRS=CRS:84&BBOX=-180,-90,180,83.604158999999996&WIDTH=660&HEIGHT=318&LAYERS=country&STYLES=default&EXCEPTIONS=xml&FORMAT=image/png&BGCOLOR=0xFEFFFF&TRANSPARENT=TRUE&layerDefs={"country":"POP_CNTRY>100000000"}
GetFeatureInfo
Filter the country layer by only obtaining information for countries that have a population greater than one million and contain a river named Amazon: layerDefs={"country":"POP_CNTRY>100000000","rivers":"NAME LIKE 'Amazon'"}.
Sample request:
http://gisserver.domain.com:6080/arcgis/services/MyMapService/MapServer/WmsServer?VERSION=1.3.0&REQUEST=GetFeatureInfo&CRS=CRS:84&BBOX=-180,-90,180,83.604158999999996&WIDTH=660&HEIGHT=318&LAYERS=country,rivers&STYLES=default,default&EXCEPTIONS=xml&FORMAT=image/png&BGCOLOR=0xFEFFFF&TRANSPARENT=TRUE&QUERY_LAYERS=country,rivers&INFO_FORMAT=text/html&I=50&J=50&layerDefs={"country":"POP_CNTRY>100000000","rivers":"NAME LIKE 'Amazon'"}