Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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!

share|improve this question
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.