In ArcGIS Javascript API 3.3, I have an ArcGISDynamicMapService layer in my application that points to a fairly simple (6 layers) map service. In the application, there is a GUI/widget that allows the user to pick various options - which then dynamically changes the layer's layerDefinitions property to re-render the layer based on their selection.

After I define and set the layerDefinitions of the layer, I call the layer.refresh method to re-render the layer. However, the re-rendered layer is always wrong - either the wrong layers are rendered, or wrong features are rendered, and there doesn't appear to be any pattern in these errors that I can determine. However, once the map is panned or zoomed, the re-rendered layer is drawn exactly as expected. Below is the relevant javascript code. The "format" function is a .NET-like string formatting function I've added to the script.

var layerDefinitions = [];
layerDefinitions[1] = "TransmitterId IN ({0})".format(visibleTransmitterIds.join(","));
layerDefinitions[2] = "TransmitterId IN ({0})".format(visibleTransmitterIds.join(","));

Using various http sniffing tools (Google Developer tools is preferred choice), I can see that the outgoing http request for my layer of interest is exactly the same between the refresh call - and the pan/zoom call. I have also verified the sql contained in the layer definitions, and am positive the layers/features returned in the refresh call are definitely wrong.

Anyone have any ideas as what may be causing this? Better yet, does anyone know an alternate way to refresh a layer without panning/zooming the map?

A couple of other notes:

  1. I have disabled cacheing at the client via setDisableClientCaching
  2. My sql where clauses make use of IN statement. Is this a bad idea with file geodatabases?
  • Please post the code you're using. Are you trying to set layerDefinitions directly? Or are you using the layer's setLayerDefinitions method? The latter is what you should be doing. help.arcgis.com/en/webapi/javascript/arcgis/jsapi/… Mar 3, 2013 at 15:46
  • Derek, please see code snippet added to original post. Also, I believe I misspoke by saying incorrect layers are being rendered. The correct layers are always drawn, its the features of the requested layers that are incorrect. When the layer refreshes at the end of the snippet above, wrong features are drawn. After a map pan/zoom, the correct features are drawn. Outgoing http request is exact same (except extent of course)
    – user890
    Mar 5, 2013 at 13:51

1 Answer 1


I believe that analysisResultLyr.setLayerDefinitions(layerDefinitions); will trigger a refresh automatically after updating the layer definitions see https://developers.arcgis.com/javascript/3/jsapi/arcgisdynamicmapservicelayer-amd.html#setlayerdefinitions. I think your call to refresh may be interfering with some async behaviour with the layer definition updates. Try removing it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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