Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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, (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? thanks!

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
can you show example? thanks! – dfghj Jul 21 '11 at 18:00

Your Answer


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

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