I wanted to add ILayer to IMap, i think it has been added but problem is that it does not display it on the website.
I am running arcgis server 10, using visual web developer 2010 express edition for web mapping application, vb.net (web adf). Here is the code:
Public Sub ServerAction(ByVal args As ToolEventArgs) _
Implements ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools.IMapServerToolAction.ServerAction
If TypeOf args.Control Is ESRI.ArcGIS.ADF.Web.UI.WebControls.Map Then
Dim map1 As ESRI.ArcGIS.ADF.Web.UI.WebControls.Map
map1 = CType(args.Control, ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)
Try
Dim mapFunc As ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality = _
CType(map1.GetFunctionality(0), ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)
Dim mrl As ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal = mapFunc.Resource
Dim sc1 As ESRI.ArcGIS.Server.IServerContext = mrl.ServerContextInfo.ServerContext
Dim mapS As ESRI.ArcGIS.Carto.IMapServer = mrl.MapServer
Dim mapSObj As IMapServerObjects = mapS
Dim pMap As ESRI.ArcGIS.Carto.IMap = mapSObj.Map(mapS.DefaultMapName)
MsgBox(pMap.Name & ": " & pMap.LayerCount)
Dim f As ILayerFile = New LayerFile()
f.Open("C:\data\a.lyr")
Dim pLayer As ILayer = f.Layer
pMap.AddLayer(pLayer)
MsgBox(pMap.Name & ": " & pMap.LayerCount)
mrl.RefreshServerObjects()
Finally
map1.Refresh()
End Try
End If
End Sub
Please can you explain or show why the added layer is not being displayed? thanks!