Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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(","));
analysisResultLyr.setLayerDefinitions(layerDefinitions);
analysisResultLyr.refresh();

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. help.arcgis.com/en/webapi/javascript/arcgis/jsapi/… –  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

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.