ArcObjects Library Reference

Add Graphics Layer to Globe Snippet

Add a new graphics layer and elements to a globe.

[C#]

///<summary>Add a new graphics layer and elements to a globe.</summary>
///      
///<param name="globe">An IGlobe interface</param>
///<param name="graphicsLayerName">A System.String that is the display name of the new graphics layer. Example: "NewGraphicsLayer"</param>
///      
///<remarks></remarks>
public void AddGraphicsLayerToGlobe(ESRI.ArcGIS.GlobeCore.IGlobe globe, System.String graphicsLayerName)
{
  // Create and add the graphics layer to ArcGlobe
  ESRI.ArcGIS.Carto.IGraphicsContainer globeGraphicsLayer = new ESRI.ArcGIS.GlobeCore.GlobeGraphicsLayerClass();
  ESRI.ArcGIS.Carto.ILayer layer = (ESRI.ArcGIS.Carto.ILayer)globeGraphicsLayer; // Explicit cast
  layer.Name = graphicsLayerName;
  ESRI.ArcGIS.Analyst3D.IScene scene = globe as ESRI.ArcGIS.Analyst3D.IScene;  // Reference or Boxing Conversion

  // Add the graphics layer
  scene.AddLayer(layer, true);

  // Add a point graphics element to the graphics layer
  ESRI.ArcGIS.Carto.IElement markerElement = new ESRI.ArcGIS.Carto.MarkerElementClass();
  ESRI.ArcGIS.Analyst3D.ISimpleMarker3DSymbol simpleMarker3DSymbol = new ESRI.ArcGIS.Analyst3D.SimpleMarker3DSymbolClass();
  simpleMarker3DSymbol.Style = ESRI.ArcGIS.Analyst3D.esriSimple3DMarkerStyle.esriS3DMSCone;

  // Set symbol color and size
  simpleMarker3DSymbol.ResolutionQuality = 1;
  ESRI.ArcGIS.Display.IColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
  rgbColor.RGB = 255;

  ESRI.ArcGIS.Display.IMarkerSymbol markerSymbol = (ESRI.ArcGIS.Display.IMarkerSymbol)simpleMarker3DSymbol; // Explicit cast
  markerSymbol.Color = rgbColor;
  markerSymbol.Size = 100000;

  // Set the geometry
  ESRI.ArcGIS.Geometry.IPoint point = new ESRI.ArcGIS.Geometry.PointClass();
  point.PutCoords(-47, 44);
  markerElement.Geometry = point;

  // Add to the graphics layer
  ESRI.ArcGIS.Carto.IMarkerElement markerElement_2 = (ESRI.ArcGIS.Carto.IMarkerElement)markerElement; // Explicit Cast
  markerElement_2.Symbol = markerSymbol;
  globeGraphicsLayer.AddElement(markerElement, 1);

  // Add a line graphics element to the graphics layer
  ESRI.ArcGIS.Carto.IElement lineElement = new ESRI.ArcGIS.Carto.LineElementClass();
  ESRI.ArcGIS.Analyst3D.ISimpleLine3DSymbol simpleLineSymbol3D = new ESRI.ArcGIS.Analyst3D.SimpleLine3DSymbolClass();
  simpleLineSymbol3D.Style = ESRI.ArcGIS.Analyst3D.esriSimple3DLineStyle.esriS3DLSStrip;

  // Set symbol color and size
  simpleLineSymbol3D.ResolutionQuality = 1;
  rgbColor.RGB = 255000;

  ESRI.ArcGIS.Display.ILineSymbol lineSymbol = (ESRI.ArcGIS.Display.ILineSymbol)simpleLineSymbol3D; //Explicit cast
  lineSymbol.Color = rgbColor;
  lineSymbol.Width = 2;

  // Set the geometry
  ESRI.ArcGIS.Geometry.IPolyline polyline = new ESRI.ArcGIS.Geometry.PolylineClass();
  ESRI.ArcGIS.Geometry.IPoint fromPoint = new ESRI.ArcGIS.Geometry.PointClass();
  fromPoint.PutCoords(-30, 44);
  polyline.FromPoint = fromPoint;
  ESRI.ArcGIS.Geometry.IPoint toPoint = new ESRI.ArcGIS.Geometry.PointClass();
  toPoint.PutCoords(-60, 44);
  polyline.ToPoint = toPoint;
  lineElement.Geometry = polyline;

  // Add to the graphics layer
  ESRI.ArcGIS.Carto.ILineElement lineElement_2 = (ESRI.ArcGIS.Carto.ILineElement)lineElement; // Explicit cast
  lineElement_2.Symbol = lineSymbol;
  globeGraphicsLayer.AddElement(lineElement, 1);
}
[Visual Basic .NET]

'''<summary>Add a new graphics layer and elements to a globe.</summary>
'''      
'''<param name="globe">An IGlobe interface</param>
'''<param name="graphicsLayerName">A System.String that is the display name of the new graphics layer. Example: "NewGraphicsLayer"</param>
'''      
'''<remarks></remarks>
Public Sub AddGraphicsLayerToGlobe(ByVal globe As ESRI.ArcGIS.GlobeCore.IGlobe, ByVal graphicsLayerName As System.String)

  ' Create and add the graphics layer to ArcGlobe
  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 = graphicsLayerName
  Dim scene As ESRI.ArcGIS.Analyst3D.IScene = CType(globe, ESRI.ArcGIS.Analyst3D.IScene) ' Explicit Cast

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

  ' Add a point graphics element to the graphics layer
  Dim markerElement As ESRI.ArcGIS.Carto.IElement = New ESRI.ArcGIS.Carto.MarkerElementClass
  Dim simpleMarker3DSymbol As ESRI.ArcGIS.Analyst3D.ISimpleMarker3DSymbol = New ESRI.ArcGIS.Analyst3D.SimpleMarker3DSymbolClass
  simpleMarker3DSymbol.Style = ESRI.ArcGIS.Analyst3D.esriSimple3DMarkerStyle.esriS3DMSCone

  ' Set symbol color and size
  simpleMarker3DSymbol.ResolutionQuality = 1
  Dim rgbColor As ESRI.ArcGIS.Display.IColor = New ESRI.ArcGIS.Display.RgbColorClass
  rgbColor.RGB = 255

  Dim markerSymbol As ESRI.ArcGIS.Display.IMarkerSymbol = CType(simpleMarker3DSymbol, ESRI.ArcGIS.Display.IMarkerSymbol) ' Explicit Cast
  markerSymbol.Color = rgbColor
  markerSymbol.Size = 100000

  ' Set the geometry
  Dim point As ESRI.ArcGIS.Geometry.IPoint = New ESRI.ArcGIS.Geometry.PointClass
  point.PutCoords(-47, 44)
  markerElement.Geometry = point

  ' 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, 1)

  ' Add a line graphics element to the graphics layer
  Dim lineElement As ESRI.ArcGIS.Carto.IElement = New ESRI.ArcGIS.Carto.LineElementClass
  Dim simpleLineSymbol3D As ESRI.ArcGIS.Analyst3D.ISimpleLine3DSymbol = New ESRI.ArcGIS.Analyst3D.SimpleLine3DSymbolClass
  simpleLineSymbol3D.Style = ESRI.ArcGIS.Analyst3D.esriSimple3DLineStyle.esriS3DLSStrip

  ' Set symbol color and size
  simpleLineSymbol3D.ResolutionQuality = 1
  rgbColor.RGB = 255000

  Dim lineSymbol As ESRI.ArcGIS.Display.ILineSymbol = CType(simpleLineSymbol3D, ESRI.ArcGIS.Display.ILineSymbol) ' Explicit Cast
  lineSymbol.Color = rgbColor
  lineSymbol.Width = 2

  ' Set the geometry
  Dim polyline As ESRI.ArcGIS.Geometry.IPolyline = New ESRI.ArcGIS.Geometry.PolylineClass
  Dim fromPoint As ESRI.ArcGIS.Geometry.IPoint = New ESRI.ArcGIS.Geometry.PointClass
  fromPoint.PutCoords(-30, 44)
  polyline.FromPoint = fromPoint
  Dim toPoint As ESRI.ArcGIS.Geometry.IPoint = New ESRI.ArcGIS.Geometry.PointClass
  toPoint.PutCoords(-60, 44)
  polyline.ToPoint = toPoint
  lineElement.Geometry = Polyline

  ' Add to the graphics layer
  Dim lineElement_2 As ESRI.ArcGIS.Carto.ILineElement = CType(lineElement, ESRI.ArcGIS.Carto.ILineElement) ' Explicit Cast
  lineElement_2.Symbol = lineSymbol
  globeGraphicsLayer.AddElement(lineElement, 1)

End Sub


Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.3DAnalyst
  • ESRI.ArcGIS.Carto
  • ESRI.ArcGIS.Display
  • ESRI.ArcGIS.Geodatabase
  • ESRI.ArcGIS.Geometry
  • ESRI.ArcGIS.GlobeCore
  • ESRI.ArcGIS.System