wmsarcgis-server

How to enable layerDefs in ArcGIS WMS?


I am trying to use ESRI vendor specific WMS parameter "layerDefs", as described here:

https://enterprise.arcgis.com/en/server/latest/publish-services/linux/filtering-features-using-the-layerdefs-parameter-in-wms-requests.htm

However, I have problem getting it to work since syntax as in the example breaks the service (server responds with "Your browser sent a request that this server could not understand"). This should be working but it doesn't:

https://alaskafisheries.noaa.gov/arcgis/services/ShoreZoneFlexMapService/MapServer/WMSServer?&service=WMS&request=GetMap&layers=53&styles=&format=image%2Fjpeg&transparent=true&version=1.1.1&width=256&height=256&srs=EPSG%3A3857&bbox=-20037508.342789244,0,-10018754.171394622,10018754.171394628&layerDefs={"53":"State='AK'"}

I know that this service supports layerDefs because it works for map service:

1) without layerDefs: https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?bbox=-16445389.266341925%2C5254576.417854222%2C-11798017.946604446%2C7896240.115389209&bboxSR=&layers=&layerDefs=&size=&imageSR=&historicMoment=&format=jpg&transparent=true&dpi=&time=&layerTimeOptions=&dynamicLayers=&gdbVersion=&mapScale=&rotation=&datumTransformations=&layerParameterValues=&mapRangeValues=&layerRangeValues=&f=html

2) with layerDefs (bottom part is excluded as it is outside Alaska):

https://alaskafisheries.noaa.gov/arcgis/rest/services/ShoreZoneFlexMapService/MapServer/export?bbox=-16445389.266341925%2C5254576.417854222%2C-11798017.946604446%2C7896240.115389209&bboxSR=&layers=&layerDefs=3%3AState%3D%27AK%27&size=&imageSR=&historicMoment=&format=jpg&transparent=true&dpi=&time=&layerTimeOptions=&dynamicLayers=&gdbVersion=&mapScale=&rotation=&datumTransformations=&layerParameterValues=&mapRangeValues=&layerRangeValues=&f=html

Note the bottom part of the pic disappears (ie. is filtered out)

In map service it is layer 3 but WMS has it listed as layer 53 (don't ask, it's ESRI!)

So, WMS url without layerDefs is as follows:

https://alaskafisheries.noaa.gov/arcgis/services/ShoreZoneFlexMapService/MapServer/WMSServer?&service=WMS&request=GetMap&layers=53&styles=&format=image%2Fjpeg&transparent=true&version=1.1.1&width=256&height=256&srs=EPSG%3A3857&bbox=-20037508.342789244,0,-10018754.171394622,10018754.171394628

But server 'doesn't understand' the request when layerDefs parameter is included.

Do you know what is the correct syntax?


Solution

  • It appears there is no way to include layerDefs parameter in ESRI WMS service. It simply doesn't work. I asked around, searched the internet and tested all possible combination I could think of. Pity, such a large company stumbles on basic functionality of their products... or doing it deliberately? Then there is lack of documentation and basic support (questions on ESRI forums remain unanswered for years... and this post had only a handful of views so far!)

    Map service option works with layerDefs (as described in my question) so that's what I am going with for now. Unfortunately, it requires extra coding. And I am not touching any of ESRI concoctions ever again...