fabpuddu

How to use Billboard Symbol with IFeatureLayer (GlobeControl)

Discussion created by fabpuddu on Apr 2, 2012
Latest reply on May 21, 2012 by fabpuddu2
Hi,

I'm trying to use a billboard symbol from style gallery in globecontrol using IFeatureLayer
but I have a problem, the symbol is showed like a rectangle and not show lik billboard

In attachments the image of my result

I can manage style gallery symbols using IFeatureLayer ? How I can do ?


thanks


This is my code:

Private m_objGlobeControl As AxGlobeControl
Private m_FeatureLayer As IFeatureLayer


Public Sub AddFeature(ByVal stDati() As st_DataTarget_3d)
        Create_Layer()
        AddingFeature(stDati)
        m_objGlobeControl.GlobeDisplay.RefreshViewers()
End Sub

Private Sub Create_Layer()

        Dim pFeatureClass As IFeatureClass
        pFeatureClass = CreateFeatureClass(esriGeometryType.esriGeometryPoint)

        Dim pFLy As IFeatureLayer
        pFLy = New FeatureLayer

        With pFLy
            .FeatureClass = pFeatureClass
            .Name = m_NameLayer
            .Cached = True
            .Selectable = True
        End With

        Dim pSymbol As ISymbol = LoadStyleSymbol()

        Dim pColor As IColor = New RgbColor
        pColor.RGB = RGB(0, 255, 0)
        pColor.Transparency = 255

        Dim markerSymbol As IMarkerSymbol = TryCast(pSymbol, IMarkerSymbol)
        markerSymbol.Color = pColor
        markerSymbol.Size = 15

        Dim pRend As IFeatureRenderer
        Dim pSimpleRend As ISimpleRenderer
        Dim pGeoFL As IGeoFeatureLayer

        If Not IsNothing(pSymbol) Then
            pRend = New SimpleRenderer
            pSimpleRend = pRend
            pSimpleRend.Symbol = markerSymbol
            pGeoFL = pFLy
            pGeoFL.Renderer = pRend
        End If

        m_objGlobeControl.Globe.AddLayerType(pFLy, esriGlobeLayerType.esriGlobeLayerTypeDraped, True)

        m_FeatureLayer = pFLy

End Sub


Private Sub AddingFeature(ByVal stDati() As st_DataTarget_3d)

        Dim pFeatureClass As IFeatureClass = Nothing
        Dim pFeature As IFeature = Nothing
        Dim pPoint As IPoint

        pFeatureClass = m_FeatureLayer.FeatureClass

        pFeature = New Feature

        For iConta As Integer = 0 To (stDati.Length - 1)

            If Not IsDBNull(stDati(iConta).Latitudine) And Not IsDBNull(stDati(iConta).Longitudine) Then

                pFeature = pFeatureClass.CreateFeature
                pPoint = New Point
                pPoint.PutCoords(stDati(iConta).Longitudine, stDati(iConta).Latitudine)

                Dim za As IZAware = TryCast(pPoint, IZAware)
                za.ZAware = True
                pPoint.Z = 25

                With pFeature
                    .Shape = pPoint
                    .Store()
                End With

            End If

        Next

End Sub


Private Function CreateFeatureClass(ByVal TipoGeometria As esriGeometryType) As IFeatureClass

        Dim pFWS As IFeatureWorkspace = Nothing
        Dim pWorkspaceFactory As IWorkspaceFactory
        Dim pWorkSpaceName As IWorkspaceName
        Dim pName As IName

        Dim pFields As IFields
        Dim pFieldsEdit As IFieldsEdit
        Dim pField As IField
        Dim pFieldEdit As IFieldEdit

        Dim pGeomDef As IGeometryDef
        Dim pGeomDefEdit As IGeometryDefEdit

        Dim pFeatClass As IFeatureClass

            pWorkspaceFactory = New FileGDBWorkspaceFactoryClass()
            pFWS = pWorkspaceFactory.OpenFromFile(My.Application.Info.DirectoryPath & "\FGDB\NEMO-TMP-FGDB.gdb", 0)
            Dim pEnumDS As IEnumDataset = TryCast(pFWS, IWorkspace).Datasets(esriDatasetType.esriDTFeatureClass)
            Dim pDS As IDataset = pEnumDS.Next
            Do Until pDS Is Nothing
                If pDS.Name = m_NameLayer Then
                    pDS.Delete()
                    Exit Do
                End If
                pDS = pEnumDS.Next
            Loop

            pFields = New Fields
            pFieldsEdit = pFields

            pField = New Field
            pFieldEdit = pField
            pFieldEdit.Name_2 = "OID"
            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID
            pFieldsEdit.AddField(pField)

            pField = New Field
            pFieldEdit = pField
            pFieldEdit.Name_2 = "Shape"
            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry

            pGeomDef = New GeometryDef
            pGeomDefEdit = pGeomDef
            With pGeomDefEdit
                .GeometryType_2 = TipoGeometria
                .SpatialReference_2 = TryCast(m_objGlobeControl.Globe, IBasicMap).SpatialReference
                .HasZ_2 = True
            End With
            pFieldEdit.GeometryDef_2 = pGeomDef
            pFieldsEdit.AddField(pField)

            pFeatClass = pFWS.CreateFeatureClass(m_NameLayer, pFields, Nothing, Nothing, esriFeatureType.esriFTSimple, "Shape", "")

            CreateFeatureClass = pFeatClass

End Function

Private Function LoadStyleSymbol() As ISymbol

        Dim styleGallery As IStyleGallery = New ServerStyleGalleryClass()
        Dim styleStorage As IStyleGalleryStorage = TryCast(styleGallery, IStyleGalleryStorage)
        styleStorage.TargetFile = "C:\Programmi\ArcGIS\Engine10.0\Styles\3D Billboards.ServerStyle"
        styleStorage.AddFile("C:\Programmi\ArcGIS\Engine10.0\Styles\3D Billboards.ServerStyle")
        Dim enumStyleGalleryItem As IEnumStyleGalleryItem = styleGallery.Items("Marker Symbols", "C:\Programmi\ArcGIS\Engine10.0\Styles\3D Billboards.ServerStyle", "")
        enumStyleGalleryItem.Reset()
        Dim styleItem As IStyleGalleryItem = enumStyleGalleryItem.Next()

        While (styleItem IsNot Nothing)
            If styleItem.Name = "Red Pushpin 3" Then
                Exit While
            End If
            styleItem = enumStyleGalleryItem.Next()
        End While
        Dim pSymbol As ISymbol = TryCast(styleItem.Item, ISymbol)

        Return pSymbol

End Function

Attachments

Outcomes