Imports ESRI.ArcGIS.SystemUI Imports ESRI.ArcGIS.esriSystem Imports ESRI.ArcGIS.Geodatabase Imports ESRI.ArcGIS.Catalog Imports ESRI.ArcGIS.Carto Namespace CustomUIElements Public Class AddLayer Inherits ESRI.ArcGIS.Desktop.AddIns.Button Public Sub New() End Sub Protected Overrides Sub OnClick() WHAT SHOULD I PUT HERE???? My.ArcMap.Application.CurrentTool = Nothing End Sub Protected Overrides Sub OnUpdate() Enabled = My.ArcMap.Application IsNot Nothing End Sub Public Sub AddLayerToActiveView(ByVal activeView As IActiveView, ByVal layerPathFile As System.String) If activeView Is Nothing OrElse layerPathFile Is Nothing OrElse (Not layerPathFile.EndsWith(".lyr")) Then Return End If ' Create a new GxLayer Dim gxLayer As IGxLayer = New GxLayerClass Dim gxFile As IGxFile = CType(gxLayer, IGxFile) 'Explicit Cast ' Set the path for where the layerfile is located on disk gxFile.Path = layerPathFile ' Test if we have a valid layer and add it to the map If Not (gxLayer.Layer Is Nothing) Then Dim map As IMap = activeView.FocusMap map.AddLayer(gxLayer.Layer) End If End Sub End Class End Namespace
Solved! Go to Solution.