DynamicMapServiceLayer does not refresh

2649
7
12-31-2010 12:04 PM
BranonBarrett
New Contributor
I have a SOE that adds/removes layers from a map service. After this happens the changes do not show up on the client side unless I refresh/reload the page (not the map). In the SOE the rest cache is refreshed after the changes to the map service have been made. On the client side I have set DisableClientCaching = true. I have an asynchronous callback method that I call the ArcGISDynamicMapServiceLayer.Refresh() method in, but nothing changes in the map. Does anyone out there have a solution for this issue, or can anyone at least share my pain!

If you don't have a solution to this issue, do you have another brilliant way to allow a user to dynamically add or remove layers? (The layer/s to add are coming from a geodatabase on the server)
0 Kudos
7 Replies
ArwenVaughan
New Contributor
I too am having this same problem Branon!! Even after clearing the rest cache using a generate token, my silverlight application does not "see" the new layer that has been added to the MapService. I have to restart the silverlight application completely or programmatically disconnect from the MapService and then reconnect. This is not a very elegant way to do this at all!!!

Does anyone have any idea how to "refresh" the connection to the MapService from a silverlight application?
0 Kudos
JDog
by
New Contributor
We have also been experimenting with the Silverlight Mapping components but am having issues when loading layers at runtime.  We are using the new RIA services which are obviously by nature Asynchronous.  We are not fully understanding the lifecycle of the loading we should be following as all documentation from ESRI shows loading layers in the XAML (is this really how everyone is using this in the real world?).

We have the details being retrieved just fine from the RIA services (Dynamic layer definition) but after adding the layer to the map, it doesn't show.  Interesting thing is it shows all layers in the Legend control, just nothing in the Map viewer control.
0 Kudos
BranonBarrett
New Contributor
We have the details being retrieved just fine from the RIA services (Dynamic layer definition) but after adding the layer to the map, it doesn't show.  Interesting thing is it shows all layers in the Legend control, just nothing in the Map viewer control.


Are you adding a layer to the underlying MXD file via your RIA service or are modifying the Map Service via a Server Object Extension? Are you just adding a layer definition, or are you actually adding the layer from IMap.AddLayer? I am using IMap.AddLayer in a SOE and  I can't get anything to show unless I reload the entire page! I'm assuming you have refreshed the REST cache as outlined here ?

If you come up with a solution to this please let me know.

Also, if any ESRI reps want to weigh in. I'm all ears.
0 Kudos
JDog
by
New Contributor
@banjopolka, We are simply adding a Service from ArcGIS server which in turn is already mapped to an MXD file.  We store themes that can be made up of several of these layers so hard coding it in the XAML will not work (still think this is a rediculous way of doing it anyway?).  If I move my code away from RIA services (which has to wait until the async retrieves the actual data) and somewhat hard code the values then the map loads fine.  It's when the app is waiting for the Async to finish retrieving the URL, ImageType, etc. that it doesn't show the particular layer in the map.  I'm examining Fiddler, etc. to see if I can figure it out and will post any findings.  Would love to hear an official way of doing this from ESRI assuming it was ever intended to be used for these purposes.  The more time I spend in the documentation and what not, the more I think ESRI assumes the user is hard coding values for a one-off application and not really open to dynamic development?  Take the ASP.net controls for example, all of the binding of layers is done through the visual designer in Visual Studio, or at least that is how all of the documentation explains it?
0 Kudos
BranonBarrett
New Contributor
We are simply adding a Service from ArcGIS server which in turn is already mapped to an MXD file.  We store themes that can be made up of several of these layers


So are you not actually modifying the MXD or the Map Service?
0 Kudos
MichelleThompson1
New Contributor II
I take it no one has gotten the DynamicMapServiceLayer.Refresh() to work? Having the same issue and it's frustrating having to refresh the whole page for perform another task that will force a refresh.

Thanks.
0 Kudos
PreetiMaske
Esri Contributor
What version of API and ArcGIS Server are you using? For ArcGIS Server, please mention if there is any servicepack installed?


Generally, in order to get the updated MapDescription, you have to call GetServerInfo on IMapServer again,

The following should be the workflow
Create IMapServer3
Remove the layer
Call IMapServerObjects.RefreshServerObjects
Create IMapServer3
Add the layer
Call IMapServerObjects.RefreshServerObjects

Sample code:

IServerContext serverContext;
IMapServer2 mapServer;
IMapDescription mapDesc;
// Access fine-grained ArcObjects
IMapServerObjects2 mapServerObj = (IMapServerObjects)mapServer;
string strMapName = mapServer.DefaultMapName;
IMap map = mapServerObj.get_Map(strMapName);

// Add a new group layer to map
IGroupLayer groupLayer = serverContext.CreateObject("esriCarto.GroupLayer") as IGroupLayer;
groupLayer.Name = "New Group Layer";
map.AddLayer(groupLayer);

// Apply changes to MapServer object
mapServerObj.RefreshServerObjects();

// Get updated MapServerInfo and MapDescription
IMapServerInfo2 mapServerInfo = mapServer.GetServerInfo(strMapName);
mapDesc = mapServerInfo.DefaultMapDescription


Let me know if this helps...If you want to provide us with your testcase, I will be more than happy to assist you..
0 Kudos