Select to view content in your preferred language

How do Import Layer file symbology in ArcEngine (no GxLayer object available)

1940
3
08-17-2010 04:39 AM
TimB
by
Occasional Contributor
I am trying to import the symbology from an existing layer file and apply it to a feature class on my map.  I am attempting this in ArcEngine.  The example below is the only way I can find to do this, however, the GxLayer object and its interface are not available in the ArcEngine library.

Any ideas?




Public Function ImportRasterRenderer(path As String) As IRasterRenderer
  Dim pGxLayer As IGxLayer
  Set pGxLayer = New GxLayer
  Dim pGxFile As IGxFile
  Set pGxFile = pGxLayer
  pGxFile.path = path

  If pGxLayer.Layer Is Nothing Then
    Exit Function
  End If
  Dim pRasterLyr As IRasterLayer
  Set pRasterLyr = pGxLayer.Layer
  Set ImportRasterRenderer = pRasterLyr.Renderer

End Function
0 Kudos
3 Replies
NeilClemmons
Honored Contributor
Use the ILayerFile interface.
0 Kudos
TimB
by
Occasional Contributor
It appears that in order to use the Ilayer interface, the layer must first be loaded into the map.  Am I correct?

If so, I was hoping to use the symbology from a layer 'file' that was on disk, not from an existing layer in the map. 

Can I still use ILayer to do this?  If so, any pointers?
0 Kudos
NeilClemmons
Honored Contributor
ILayerFile, not ILayer.
0 Kudos