Changes To VisibleLayers Does Not Always Refresh Map

549
4
10-14-2010 12:55 PM
RyanCoodey
Occasional Contributor III
I have a TOC control that when a Services layer is turned on or off it updates the ArcGISDynamicMapServiceLayer VisibleLayers collection.  About 60% of the time the map refreshes just fine and shows the new changes.  But a lot of the time (way too often) it does not update... the maps progress bar always pops up (so it detects the change) but it will then hang at like 96%.  I can do a quick little pan and then it will reload and the layer changes happen.

I have also seen this behavior happen maybe about 5% of the time when just doing a pan or zoom on the map... where the progress bar stops at like 80 - 99% and doesn't go away until another pan or zoom occurs.

Any ideas on why this happens?  Also, is there a way to programmatically force the map to refresh (Map.UpdateLayout() doesn???t seem to)?

Thanks a lot for any help!!!
0 Kudos
4 Replies
DaveTimmins
Occasional Contributor II
Are you calling Refresh() on the layer?

var mapLayer = (ArcGISDynamicMapServiceLayer)Map.Layers["SomeLayer"];
mapLayer.VisibleLayers = new [] {1,3,4};
mapLayer.Refresh();
0 Kudos
RyanCoodey
Occasional Contributor III
Thanks for the reply Dave!

I still get the same temperamental behavior though :(.  I am doing this:

((ArcGISDynamicMapServiceLayer)Service).VisibleLayers = VisibleLayerIDs.ToArray();
((ArcGISDynamicMapServiceLayer)Service).Refresh();
0 Kudos
dotMorten_esri
Esri Notable Contributor
What does fiddler say?
0 Kudos
RyanCoodey
Occasional Contributor III
The times when the map does work, fiddler shows the http image start downloading and then finish...
The times when the map does NOT work, fiddler does not show anything (no activity at all in fiddler)...

Also, another interesting observation:  When there is only one of the services sub layers turned on, it seems to work every time, but if a few layers are turned on, that is when it is temperamental.

Thanks SharpGIS!
0 Kudos