Trying to use ArcGISDynamicMapServiceLayer to display RasterDataSource

2258
2
Jump to solution
06-22-2016 10:08 AM
JoanneMcGraw
Occasional Contributor III

Using ESRI JSAPI 3.16 and ArcGIS Server 10.4, I'm trying to work out how to display a user-specified TIF using a dynamic workspace associated with a ArcGISDynamicMapServiceLayer. So far, no luck. When I look at the REST request that is being submitted when I add my defined layer to the map, none of the dynamic information is being passed along so I end up with a blank image returned.

I've tried various convolutions of JavaScript code to do this. At the moment, my code is like this:

        var rasterDataSource = new RasterDataSource();
        rasterDataSource.workspaceId = "rasters";
        rasterDataSource.dataSourceName = "cr_rc.tif";

        var layerDataSource = new LayerDataSource();
        layerDataSource.dataSource = rasterDataSource;
        layerDataSource.type = "raster"

        var dynamicLayerInfo = new DynamicLayerInfo();
        dynamicLayerInfo.source = layerDataSource;

        var rasterLayer = new ArcGISDynamicMapServiceLayer(
            "http://<domain>/arcgis/rest/services/dynWS/MapServer"
            ,{
                dynamicLayerInfos:[
                    dynamicLayerInfo
                ]
            }
        );
        map.addLayer(rasterLayer);

     

The export request that is sent by the map.addLayer functionality is:

http://<domain>/arcgis/rest/services/dynWS/MapServer/export?dpi=96&transparent=true&format=png8&bbox=-14468865.117896732,3183946.947948264,-5594831.882103268,10296871.052051734&bboxSR=3857&imageSR=3857&size=907,727&f=image

Now, I can get the image I want with an export request that looks like this (decoded here, of course):

http://<domain>/arcgis/rest/services/dynWS/MapServer/export?dpi=96&transparent=true&format=png8&bbox=-14468865.117896732,3183946.947948264,-5594831.882103268,10296871.052051734&bboxSR=3857&imageSR=3857&size=907,727&f=image&dynamicLayers=[

{

  "source":{

    "type": "dataLayer",

    "dataSource": {

      "type": "raster",

      "workspaceId":"rasters",

      "dataSourceName": "cr_rc.tif"

    }

  }

}

]

I just can't figure out how to get the JSAPI to tack on the dynamicLayers parameter to its export request. At least, I think that's my only problem.

Can anyone provide any suggestions regarding what I am missing or doing incorrectly here?

Cheers,

jtm

1 Solution

Accepted Solutions
JoanneMcGraw
Occasional Contributor III

Finally figured it out...

For anyone else trying to do same, the only changes from my code suggestion above are because, I assume, I can't set the dynamicLayerInfo property with the options when I instantiate the ArcGISDynamicMapServiceLayer.

Instead, I do this (the rest of the code snippet above is the same):

        var rasterLayer = new ArcGISDynamicMapServiceLayer(
             "http://<domain>/arcgis/rest/services/dynWS/MapServer"
             ,{
                 imageTransparency: true
             }
        );

        rasterLayer.setDynamicLayerInfos(
             [
                 dynamicLayerInfo
             ]
        );

        map.addLayer(rasterLayer); 

And I get the raster in question displayed in the Map object. Yay!

View solution in original post

2 Replies
JoanneMcGraw
Occasional Contributor III

Finally figured it out...

For anyone else trying to do same, the only changes from my code suggestion above are because, I assume, I can't set the dynamicLayerInfo property with the options when I instantiate the ArcGISDynamicMapServiceLayer.

Instead, I do this (the rest of the code snippet above is the same):

        var rasterLayer = new ArcGISDynamicMapServiceLayer(
             "http://<domain>/arcgis/rest/services/dynWS/MapServer"
             ,{
                 imageTransparency: true
             }
        );

        rasterLayer.setDynamicLayerInfos(
             [
                 dynamicLayerInfo
             ]
        );

        map.addLayer(rasterLayer); 

And I get the raster in question displayed in the Map object. Yay!

StefanOffermann
Occasional Contributor II

Hello Joanne,

thanks for your example, now I can use a raster file from a registered folder to use a dynamic raster file in my service. However, the renderer from the service is not used to diplay the image vie Export Map function. Instead, a black and white stretch is used for drawing the raster. Did you manage to use the symbology of the service for a dynamic raster in your map service?

My Request looks like this:

https://localhost:6443/arcgis/rest/services/DynRaster/MapServer/export?bbox=97540.59674654296,516063...[{"source":{"type": "dataLayer","dataSource":{"type": "raster","workspaceId": "RasterFolder","dataSourceName": "TAMM_01_1881_01s.tif"}}}]&gdbVersion=&mapScale=&rotation=&f=html

This is the value for dynamicLayers, human-readable:

[{
  "source": {
    "type": "dataLayer",
    "dataSource": {
      "type": "raster",
      "workspaceId": "RasterFolder",
      "dataSourceName": "TAMM_01_1881_01s.tif"
    }
  }
}]
0 Kudos