How to display symbol frol ServerStyle

612
7
03-14-2012 03:27 AM
FabrizioPuddu
New Contributor
hi,

I try to display the symbol, example 3D Billboards.ServerStyle, on arcglobe control. I get ISymbol from gallery and add a GraphicsLayer, but the symbol is not display fine, it's under the data surface.

this is my code:


Dim globeGraphicsLayer As ESRI.ArcGIS.Carto.IGraphicsContainer = New ESRI.ArcGIS.GlobeCore.GlobeGraphicsLayerClass
Dim layer As ESRI.ArcGIS.Carto.ILayer = CType(globeGraphicsLayer, ESRI.ArcGIS.Carto.ILayer) 'Explicit Cast
layer.Name = "PIPPO"
Dim scene As ESRI.ArcGIS.Analyst3D.IScene = CType(Me.m_objGlobeControl.Globe, ESRI.ArcGIS.Analyst3D.IScene) ' Explicit Cast
scene.AddLayer(layer, True)

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 = New SimpleMarkerSymbolClass()
pSymbol = TryCast(styleItem.Item, ISymbol)

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

Dim point As ESRI.ArcGIS.Geometry.IPoint = New ESRI.ArcGIS.Geometry.PointClass
point.PutCoords(35.4802, 33.9008)

Dim pMarkerElement As IMarkerElement = New MarkerElementClass()
Dim markerSymbol As IMarkerSymbol = TryCast(pSymbol, IMarkerSymbol)
markerSymbol.Color = pColor
markerSymbol.Size = 200

Dim pElement As IElement = TryCast(pMarkerElement, IElement)
pElement.Geometry = point

pMarkerElement.Symbol = markerSymbol

Dim markerElement_2 As ESRI.ArcGIS.Carto.IMarkerElement = CType(pMarkerElement, ESRI.ArcGIS.Carto.IMarkerElement) ' Explicit Cast
markerElement_2.Symbol = markerSymbol
globeGraphicsLayer.AddElement(pMarkerElement, 1)


thanks
0 Kudos
7 Replies
NeilClemmons
Regular Contributor III
You're not giving the point a z value so the element is being positioned at the coordinates you gave it but at elevation 0.  When you create the point, make it z aware and give it an appropriate value.
0 Kudos
FabrizioPuddu
New Contributor
ahhh you are right Neil, I have correct my code but the symbol is on horizontal plane and not in 3d.
Are you sure that my code is correct ? because I suppose it should be used an 3d object (marker)

thanks for your effort

fabrizio

my code correct:



Dim globeGraphicsLayer As ESRI.ArcGIS.Carto.IGraphicsContainer = New ESRI.ArcGIS.GlobeCore.GlobeGraphicsLayerClass
Dim layer As ESRI.ArcGIS.Carto.ILayer = CType(globeGraphicsLayer, ESRI.ArcGIS.Carto.ILayer) 'Explicit Cast
layer.Name = "PIPPO"
Dim scene As ESRI.ArcGIS.Analyst3D.IScene = CType(Me.m_objGlobeControl.Globe, ESRI.ArcGIS.Analyst3D.IScene) ' Explicit Cast
scene.AddLayer(layer, True)

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 = New SimpleMarkerSymbolClass()
pSymbol = TryCast(styleItem.Item, ISymbol)

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

Dim point As ESRI.ArcGIS.Geometry.IPoint = New ESRI.ArcGIS.Geometry.PointClass
point.PutCoords(35.4802, 33.9008)

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

Dim pMarkerElement As IMarkerElement = New MarkerElementClass()
Dim markerSymbol As IMarkerSymbol = TryCast(pSymbol, IMarkerSymbol)
markerSymbol.Color = pColor
markerSymbol.Size = 200

Dim pElement As IElement = TryCast(pMarkerElement, IElement)
pElement.Geometry = point

pMarkerElement.Symbol = markerSymbol

Dim markerElement_2 As ESRI.ArcGIS.Carto.IMarkerElement = CType(pMarkerElement, ESRI.ArcGIS.Carto.IMarkerElement) ' Explicit Cast
markerElement_2.Symbol = markerSymbol
globeGraphicsLayer.AddElement(pMarkerElement, 1)
0 Kudos
NeilClemmons
Regular Contributor III
The problem may be here:

Dim pSymbol As ISymbol = New SimpleMarkerSymbolClass()
pSymbol = TryCast(styleItem.Item, ISymbol)

Don't set the symbol to a new instance of the SimpleMarkerSymbolClass.  Just do this:

Dim pSymbol As ISymbol = TryCast(styleItem.Item, ISymbol)

The symbol probably isn't a SimpleMarkerSymbol but a Marker3DSymbol.
0 Kudos
FabrizioPuddu
New Contributor
in my previous post I forgot the attachment with the image, I change :

Dim pSymbol As ISymbol = New SimpleMarkerSymbolClass()
pSymbol = TryCast(styleItem.Item, ISymbol)

in:

Dim pSymbol As ISymbol = TryCast(styleItem.Item, ISymbol)

but the result is the same

thanks
0 Kudos
FabrizioPuddu
New Contributor
anyone can help me

thanks
0 Kudos
NeilClemmons
Regular Contributor III
There are probably other properties you need to set on the symbol.  It looks like the 3d marker symbol classes all implement IMarker3DPlacement so try setting the various properties on that interface and see if it does what you want.
0 Kudos
FabrizioPuddu
New Contributor
thanks Neil you are very kind,

I solved it now.

I have to used and set IGlobeGraphicsElementProperties, but very important I have to used IGlobeGraphicsLayer
It works fine

        ' Create and add the graphics layer to ArcGlobe
        Dim globeGraphicsLayer As IGlobeGraphicsLayer = New ESRI.ArcGIS.GlobeCore.GlobeGraphicsLayerClass
        Dim layer As ESRI.ArcGIS.Carto.ILayer = CType(globeGraphicsLayer, ESRI.ArcGIS.Carto.ILayer) 'Explicit Cast
        layer.Name = "PIPPO"
        Dim scene As ESRI.ArcGIS.Analyst3D.IScene = CType(Me.m_objGlobeControl.Globe, ESRI.ArcGIS.Analyst3D.IScene) ' Explicit Cast

        ' Add the graphics layer
        scene.AddLayer(layer, True)

        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)

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

        Dim pMarkerElement As IMarkerElement = New MarkerElementClass()
        Dim markerSymbol As IMarkerSymbol = TryCast(pSymbol, IMarkerSymbol)
        markerSymbol.Color = pColor
        markerSymbol.Size = 25

        ' Set the geometry
        Dim point As ESRI.ArcGIS.Geometry.IPoint = New ESRI.ArcGIS.Geometry.PointClass
        point.PutCoords(35.4802, 33.9008)

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

        Dim markerElement As ESRI.ArcGIS.Carto.IElement = New ESRI.ArcGIS.Carto.MarkerElementClass
        markerElement.Geometry = point

        '
        Dim GlobeGraphicsProps As IGlobeGraphicsElementProperties = New GlobeGraphicsElementProperties
        GlobeGraphicsProps.FixedScreenSize = True
        GlobeGraphicsProps.Rasterize = False


        ' Add to the graphics layer
        Dim markerElement_2 As ESRI.ArcGIS.Carto.IMarkerElement = CType(markerElement, ESRI.ArcGIS.Carto.IMarkerElement) ' Explicit Cast
        markerElement_2.Symbol = markerSymbol
        globeGraphicsLayer.AddElement(markerElement, GlobeGraphicsProps, 1)
0 Kudos