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)

            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()
            Dim pLayer As ILayer = f.Layer

            MsgBox(pMap.Name & ": " & pMap.LayerCount)

        End Try

    End If
End Sub

Please can you explain or show why the added layer is not being displayed?


You are creating the layer instance on the webserver. You need to create it on the server using IServerContext.CreateObject().

This of course means the .lyr file must be either placed on the ArcGIS Server SOC, or be placed on a network share from which it is accessible.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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