gm3 icon indicating copy to clipboard operation
gm3 copied to clipboard

Support for 'layers' param when map source type = ags

Open tchaddad opened this issue 4 years ago • 6 comments

For AGS sources, OpenLayers supports a params option called LAYERS:

https://openlayers.org/en/v5.3.0/apidoc/module-ol_source_TileArcGISRest.html

This lets the user specify a single feature services from an endpoint that provides more than one

Example map source:

<map-source name="statewaters" type="ags">
       <url>https://maps.dsl.state.or.us/arcgis/rest/services/Maps/StateOwnedWaters_20/MapServer</url>
       <layer name="0"/>                           <!-- River mile -->
       <layer name="1"/>                           <!-- Head of Tide -->
       <layer name="3"/>                           <!-- Waterways -->
       <param name="FORMAT" value="image/png"/>
       <param name="TRANSPARENT" value="TRUE"/>
       <param name="cross-origin" value="anonymous"/>
</map-source>

Catalog entry:

      <layer title="River Mile" src="stateownedwaters/0" />
      <layer title="Head of Tide" src="stateownedwaters/1"  />	
      <layer title="Waterways" src="stateownedwaters/3"  />		
```	

When making a request to the AGS service, GM sends a request that looks like this :

https://maps.dsl.state.or.us/arcgis/rest/services/Maps/StateOwnedWaters_20/MapServer/export?F=image&FORMAT=PNG32&TRANSPARENT=true&SIZE=256%2C256&BBOX=-13790462.895098358%2C5562169.674255706%2C-13785570.925288107%2C5567061.6440659575&BBOXSR=3857&IMAGESR=3857&DPI=90

No LAYERS parameter is specified so the AGS service returns all layers by default:

![](https://maps.dsl.state.or.us/arcgis/rest/services/Maps/StateOwnedWaters_20/MapServer/export?F=image&FORMAT=PNG32&TRANSPARENT=true&SIZE=256%2C256&BBOX=-13790462.895098358%2C5562169.674255706%2C-13785570.925288107%2C5567061.6440659575&BBOXSR=3857&IMAGESR=3857&DPI=90)

The desired behavior is that the request looks like this:

https://maps.dsl.state.or.us/arcgis/rest/services/Maps/StateOwnedWaters_20/MapServer/export?F=image&FORMAT=PNG32&TRANSPARENT=true&SIZE=256%2C256&BBOX=-13790462.895098358%2C5562169.674255706%2C-13785570.925288107%2C5567061.6440659575&BBOXSR=3857&IMAGESR=3857&DPI=90&layers=show:0

Which allows any single single layer to be requested:

![](https://maps.dsl.state.or.us/arcgis/rest/services/Maps/StateOwnedWaters_20/MapServer/export?F=image&FORMAT=PNG32&TRANSPARENT=true&SIZE=256%2C256&BBOX=-13790462.895098358%2C5562169.674255706%2C-13785570.925288107%2C5567061.6440659575&BBOXSR=3857&IMAGESR=3857&DPI=90&layers=show:0)

Note the addition of: 

``` &layers=show:0 ```

to get this to work

If the endpoint had a large number of feature classes available, you could specify any combination of them using:

```layers=show:2,4,7,12```

etc.

Leaving the layers parameter off the request triggers the default response of the AGS endpoint, which is to return all feature classes available as a single image (useful behavior sometimes, just not all the time!). 

additional info:
https://developers.arcgis.com/rest/services-reference/export-map.htm

tchaddad avatar Mar 19 '20 14:03 tchaddad