I have two problems with ArcGIS Server's (10.0) dynamic layers when calling Layer.setLayerDrawingOptions from v3.2 of the JavaScript API.

1) It doesn't work. I set the layerDrawingOptions array for a dynamic layer and the resulting image is rendered the same as if I hadn't changed anything. I have verified that the layer ID is correct, and also tried several approaches to defining the LayerDrawingOptions object.

When I inspect the request that goes to my map server it contains the following dynamicLayers property:

[{"id":0,"source":{"type":"mapLayer","mapLayerId":0},"definitionExpression":"ASSET_ID IS NULL"},{"id":1,"source":{"type":"mapLayer","mapLayerId":1},"definitionExpression":"ASSET_ID IN (27)","drawingInfo":{"renderer":{"type":"simple","symbol":{"color":[255,0,0,255],"outline":{"color":[0,0,0,255],"width":1,"type":"esriSLS","style":"esriSLSSolid"},"type":"esriSFS","style":"esriSFSSolid"}},"transparency":1,"scaleSymbols":false,"showLabels":false}},{"id":2,"source":{"type":"mapLayer","mapLayerId":2},"definitionExpression":"ASSET_ID IS NULL"},{"id":3,"source":{"type":"mapLayer","mapLayerId":3},"definitionExpression":"ASSET_ID IS NULL"}]

The feature with ASSET_ID = 27 is rendered but in its default style, however "color":[255,0,0,255] says it should be solid red. The map service referenced by this layer only contains a single polygon layer and that is ID 1. I can't see any way that I am accidentally attempting to style the wrong layer.

2) If I define multiple layerDrawingOptions in the array, one for each layer within the map service, I am forced to provide a proxy URL (even though the resulting request is nowhere near the 2000 character limit). When what should be the map request goes to the map server via the proxy, with multiple layerDrawingOptions, the map server returns a JSON string that describes an image (height, width, bbox etc.) but has an empty href ("").

Although there are no errors in my AGS log I assume this means I'm not allowed to set multiple layerDrawingOptions in a single layer. Is this actually true?

So if anyone can provide thoughts or experience on 1) why layerDrawingOptions seem to have no effect, or 2) why I am seemingly not allowed to set more than one option for a map service, I'd really love to hear it/them.


Dynamic layers require ArcGIS Server 10.1. This is documented in the some classes in the JS API that interact with dynamic layers: LayerDrawingOptions and LayerDataSource.

It's also here, albeit buried: http://resources.arcgis.com/en/help/main/10.1/#/What_s_new_in_ArcGIS_Server/016w00000036000000/

The relevant piece is the "Map services allow clients to change layer appearance and behavior dynamically" section:

Clients of ArcGIS for Server, such as the ArcGIS web APIs, can change layer appearance and behavior in a map service dynamically. Behaviors such as which layers will appear in a map, layer symbology, layer order and position, and labeling can be achieved on the server through the use of dynamic layers. In this way, dynamic layers can increase the amount of interaction that users are able to have with your maps.

  • Noooooooooooooooooooooo... well thanks so much for pointing out what I have no idea how I missed. Fortunately my project is in the process of upgrading to 10.1 so no need to enter the destructive rage just yet! p.s. I think the introduction of this functionality is a massive step forward for the REST API, perfect for creating a selection set and as functionally useful as being able to send an SLD with a WMS request.
    – tomfumb
    Oct 13 '12 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.