[Visual Basic 6.0]'Create a graphics layer and add it to globe, then add different symbol elements:
' 1. Simple point marker
' 2. Point with Picture
' 3. Point with 3D Marker
' 4. Point with Textured 3D Marker
' 5. MultiPatch
' 6. Polygon
' 7. Text element with custom element propertiesSub AddGlobeGraphics()
' Get the globe scene
Dim pGMxDoc As IGMxDocument
Set pGMxDoc = ThisDocument
Dim pScene As IScene
Set pScene = pGMxDoc.Scene
' Create a graphics layer and add it to the scene
Dim pGrLayer As IGraphicsContainer3D
Set pGrLayer = New GlobeGraphicsLayer
Dim pLayer As ILayer
Set pLayer = pGrLayer
pLayer.Name = "My Graphics"
pScene.AddLayer pLayer
Set pScene.ActiveGraphicsLayer = pLayer
' ADD GRAPHICS ELEMENTS
' Prepare the geometry etc.
Dim pGeometry As IGeometry
Set pGeometry = New Point
Dim pPoint As IPoint
Set pPoint = pGeometry
Dim pZA As IZAware
Set pZA = pPoint
pZA.ZAware = True 'important: to make sure the Z of the point can be used
Dim pColor As IColor
Set pColor = New RgbColor
Dim pElement As IElement 'to be re-used/recycled later on' 1. Simple point marker:
pPoint.PutCoords 45#, 30#
pPoint.Z = 0#Set pElement = New MarkerElement
pElement.Geometry = pGeometry
Dim pMarker As IMarkerSymbol
Set pMarker = New SimpleMarkerSymbol
pColor.RGB = RGB(255, 0, 0)
pMarker.Color = pColor
Dim pMarkerElement As IMarkerElement
Set pMarkerElement = pElement
pMarkerElement.Symbol = pMarkerpGrLayer.AddElement pElement
' 2. Point with Picture:
pPoint.PutCoords 60#, 60#
pPoint.Z = 0#Set pElement = New MarkerElement
pElement.Geometry = pPoint
Dim pPMSymbol As IPictureMarkerSymbol
Set pPMSymbol = New PictureMarkerSymbol
pPMSymbol.CreateMarkerSymbolFromFile esriIPictureBitmap, "c:\temp\picture.bmp"
pPMSymbol.size = 10
pColor.RGB = RGB(255, 0, 255)
pPMSymbol.BitmapTransparencyColor = pColor
Set pMarkerElement = pElement
pMarkerElement.Symbol = pPMSymbolpGrLayer.AddElement pElement
' 3. Point with 3D Marker (a cone):
pPoint.PutCoords -60, 45
pPoint.Z = 500000Set pElement = New MarkerElement
Dim p3DMarker As ISimpleMarker3DSymbol
Set p3DMarker = New SimpleMarker3DSymbol
p3DMarker.Style = esriS3DMSCone
p3DMarker.ResolutionQuality = 1#
Dim pMarkerSym As IMarkerSymbol
Set pMarkerSym = p3DMarker
pColor.RGB = RGB(255, 80, 255)
pMarkerSym.Color = pColor
pMarkerSym.size = 1000000 ' meters
pElement.Geometry = pPoint
Set pMarkerElement = pElement
pMarkerElement.Symbol = pMarkerSympGrLayer.AddElement pElement
' 4. Point with Textured 3D Marker:
pPoint.PutCoords -40, 87
pPoint.Z = 0Set pElement = New MarkerElement
Dim pComplex3DSym As IMarker3DSymbol
Set pComplex3DSym = New Marker3DSymbol
pComplex3DSym.CreateFromFile "d:\temp\house.flt"
Set pMarkerSym = pComplex3DSym
Dim p3DPlace As IMarker3DPlacement
Set p3DPlace = pComplex3DSym
pColor.RGB = RGB(255, 255, 255)
pColor.Transparency = 255
pMarkerSym.Color = pColor
pMarkerSym.size = 400000#
pElement.Geometry = pPoint
Set pMarkerElement = pElement
pMarkerElement.Symbol = pMarkerSympGrLayer.AddElement pElement
' 5. MultiPatch (a cylinder, taken from a 3D Symbol):
Set p3DMarker = New SimpleMarker3DSymbol
p3DMarker.Style = esriS3DMSCylinder
p3DMarker.ResolutionQuality = 0.5
Set pMarkerSym = p3DMarker
pMarkerSym.Color = pColor
Dim pMarker3DPlacement As IMarker3DPlacement
Set pMarker3DPlacement = p3DMarker
pMarker3DPlacement.MaintainAspectRatio = False
pMarkerSym.size = 3000000# ' height in meters
pMarker3DPlacement.Width = 10# ' in decimal degrees
pMarker3DPlacement.Depth = 10#
pPoint.PutCoords 0#, 0#
pPoint.Z = 0#
pMarker3DPlacement.ZOffset = 500000
pMarker3DPlacement.ApplyToPoint pPoint, pGeometry, 0#, 0#, 1#
Set pElement = New MultiPatchElement
Dim pFillSym As ISimpleFillSymbol
Set pFillSym = New SimpleFillSymbol
pColor.RGB = RGB(255, 255, 0)
pFillSym.Color = pColor
pElement.Geometry = pGeometry
Dim pFillElement As IFillShapeElement
Set pFillElement = pElement
pFillElement.Symbol = pFillSympGrLayer.AddElement pElement
' 6. Polygon:
Set pElement = New PolygonElement
Set pGeometry = New Polygon
Dim pPoints As IPointCollection
Set pPoints = pGeometryWith pPoint
.PutCoords 0#, 30#
.Z = 2000000
pPoints.AddPoint pPoint
.PutCoords -60#, 30#
.Z = 1500000
pPoints.AddPoint pPoint
.PutCoords -60#, -30#
.Z = 1500000
pPoints.AddPoint pPoint
.PutCoords 0#, -30#
.Z = 2000000
pPoints.AddPoint pPoint
End WithpColor.RGB = RGB(0, 255, 0)
pColor.Transparency = 120
pFillSym.Color = pColorpElement.Geometry = pGeometry
Set pFillElement = pElement
pFillElement.Symbol = pFillSympGrLayer.AddElement pElement
' 7. Text element:
Set pElement = New TextElement
Set pGeometry = New Point
Set pPoint = pGeometry
pPoint.PutCoords 35#, 35#
pPoint.Z = 0#Dim pTextSym As ITextSymbol
Set pTextSym = New TextSymbol
pColor.RGB = RGB(200, 255, 100)
pColor.Transparency = 255
pTextSym.Color = pColor
pTextSym.size = 20
Dim pFontDisp As stdole.IFontDisp
Set pFontDisp = New stdole.StdFont
With pFontDisp
.Name = "Arial"
.size = 20
.Weight = 400
.Italic = False
.Underline = False
.Strikethrough = False
End With
pTextSym.Font = pFontDisppTextSym.HorizontalAlignment = esriTHACenter
pTextSym.VerticalAlignment = esriTVABottompElement.Geometry = pGeometry
Dim pTextElement As ITextElement
Set pTextElement = pElement
pTextElement.Symbol = pTextSym
pTextElement.Text = "This is a test"
'pGrLayer.AddElement pElement ' adds the text element with default properties
' Use Properties object to add a callout line and local orientation to the text, which are not default
Dim pProps As IGlobeGraphicsElementProperties
Set pProps = New GlobeGraphicsElementProperties
pProps.Illuminate = False
pProps.FixedScreenSize = True
pProps.OrientationMode = esriGlobeGraphicsOrientationLocal
'pProps.OrientationMode = esriGlobeGraphicsOrientationBillboard' Define the callout line:
pProps.UseCallOutLine = True
pColor.RGB = RGB(255, 0, 0)
Dim pLineSym As ISimpleLineSymbol
Set pLineSym = New SimpleLineSymbol
pLineSym.Color = pColor
pLineSym.Width = 3#
pProps.CallOutLineSymbol = pLineSym
pProps.PutCallOutLineOffset 2#, 5#, 200000 ' geographic' Add the same text element with custom properties
Dim pGlobeGraphicsLayer As IGlobeGraphicsLayer
Set pGlobeGraphicsLayer = pGrLayer
MsgBox pGlobeGraphicsLayer.IsHidden
pGlobeGraphicsLayer.AddElement pElement, pProps, 0' Refresh view
Dim pGlobe As IGlobe
Set pGlobe = pScene
Dim pGDisplay As IGlobeDisplay
Set pGDisplay = pGlobe.GlobeDisplay
pGDisplay.RefreshViewersEnd Sub
[Visual Basic .NET, C#, C++]
No example is available for Visual Basic .NET, C#, or C++. To view a Visual Basic 6.0 example, click the Language Filter button
in the upper-left corner of the page.