esriRequest with multiple map layers

375
4
11-07-2019 01:58 PM
GregoryBologna
Occasional Contributor

How do I return multiple layers including a map layer that is a definitionExpression when doing an esriRequest?

If I request a single map layer that is a definitionExpression, the map layer is returned.

      {
         "id": 1,
            "layerDefinition": {
               "drawingInfo": drawingInfo,
                  "source": {
                     "type": "mapLayer",
                       "mapLayerId": 1
                  },
                  "definitionExpression": "PARID='"+parid+"'"
         }
      }

If I request two map layers, one with a definitionExpression, no map layers are returned. 

"layers": [  {  "id": 256,

      "layerDefinition": {

            "source": {

                  "type": "mapLayer", "mapLayerId": 256 }
             }
      },

      {
         "id": 1,
            "layerDefinition": {
               "drawingInfo": drawingInfo,
                  "source": {
                     "type": "mapLayer",
                       "mapLayerId": 1
                  },
                  "definitionExpression": "PARID='"+parid+"'"
         }
      }

If I request a single map layer that is not a definitionExpression, the map layer is returned.

Example of map a single map layer shown in black text and white background

Tags (1)
0 Kudos
4 Replies
Noah-Sager
Esri Regular Contributor

Can you post some code that shows what you are trying to accomplish? What version of the JS API are you using? I'm not sure how you're using esriRequest or what you mean by mapLayer.

0 Kudos
GregoryBologna
Occasional Contributor

I am constructing a json esriRequest and posting it to Printing Tools Task. The "layers" are in the request.

Post:

https://gis.foobar.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Ta...

Raw request:

{"mapOptions":{"showAttribution":false,"extent":{"xmin":479389.87880438194,"ymin":1159369.4997793399,"xmax":479840.91235113516,"ymax":1159594.2281684615,"spatialReference":{"wkid":102659}},"spatialReference":{"wkid":102659},"rotation":0},"operationalLayers":[{"id":"World_Street_Map_417","title":"World_Street_Map_417","opacity":1,"minScale":0,"maxScale":0,"url":"https://www.foobar.org/arcgis01/rest/services/basemap/aerials/MapServer"},{"id":"WebLayers_2139","title":"WebLayers_2139","opacity":1,"minScale":0,"maxScale":0,"url":"https://gis.foobar.com/arcgis/rest/services/Website/WebLayers/MapServer","layers":[{"id":1,"layerDefinition":{"drawingInfo":{"renderer":{"type":"simple","symbol":{"type":"esriSFS","style":"esriSFSNull","outline":{"type":"esriSLS","style":"esriSLSSolid","color":[66,244,206],"width":3}}}},"source":{"type":"mapLayer","mapLayerId":1},"definitionExpression":"FOOBAR='1014100000'"}}]}],"exportOptions":{"outputSize":[400,400],"dpi":96}}

Encoded request:

https://gis.foobar.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task/execute?Web_Map...foobar.org%2Farcgis01%2Frest%2Fservices%2Fbasemap%2Faerials%2FMapServer%22%7D%2C%7B%22id%22%3A%22WebLayers...foobar.com%2Farcgis%2Frest%2Fservices%2FWebsite%2FWebLayers%2FMapServer%22%2C%22layers%22%3A%5B%7B%22id%22...

0 Kudos
Noah-Sager
Esri Regular Contributor

Ok, sorry, I don't know how to help. What version of the JS API are you using? Are the layers MapImageLayers or FeatureLayers? 

0 Kudos
GregoryBologna
Occasional Contributor

JS 4.13 feature layers

0 Kudos