Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?
share|improve this question
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.… – Derek Swingley Mar 3 '13 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 '13 at 13:51

I believe that analysisResultLyr.setLayerDefinitions(layerDefinitions); will trigger a refresh automatically after updating the layer definitions see I think your call to refresh may be interfering with some async behaviour with the layer definition updates. Try removing it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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