Hi,
I have been trying to add a layer(.lyr) and i am unable to add it since i am a beginner in vb.net. After running it I can see only the TOC of the layer but not the image.
The code I have used is as follows.
Can someone correct my code.
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Obtain the object factory interface from the app
Dim pObjFactory As IObjectFactory = CType(m_pApp, IObjectFactory)
'Get a reference to the ArcMap document and the focus map
Dim pMxDoc As IMxDocument = CType(m_pDoc, IMxDocument)
Dim pMap As IMap = CType(pMxDoc.FocusMap, IMap)
Call AddLayerFromFile(pMap, "G:\Deepak\map_mumbai_final.jpg.lyr")
End Sub
Public Sub AddLayerFromFile(ByVal map As ESRI.ArcGIS.Carto.IMap, ByVal layerPathFile As String)
'Create a new GxLayer.
Dim gxLayerCls As ESRI.ArcGIS.Catalog.IGxLayer = New ESRI.ArcGIS.Catalog.GxLayer
Dim gxFile As ESRI.ArcGIS.Catalog.IGxFile = gxLayerCls 'Implicit Cast.
'Set the path for where the layer file is located on disk.
gxFile.Path = layerPathFile
'Test if you have a valid layer and add it to the map.
map.AddLayer(gxLayerCls.Layer)
End Sub