ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMLineGraphic Class / ToJson Method
The JSON serialization settings.
Example

In This Topic
    ToJson Method (CIMLineGraphic)
    In This Topic
    Creates a JSON encoding of the CIMLineGraphic and its current state.
    Syntax
    Public Overrides Function ToJson( _
       Optional ByVal settings As JsonSerializationSettings _
    ) As String
    public override string ToJson( 
       JsonSerializationSettings settings
    )

    Parameters

    settings
    The JSON serialization settings.
    Example
    Line Graphic Element using CIMGraphic
    {
      // Note: must be called on the QueuedTask
      {
        //On the QueuedTask
        //Place a line symbol using the extent's lower left and upper right corner.
        var extent = MapView.Active.Extent;
        //get the lower left corner of the extent
        var pointFromCoordinates = new Coordinate2D(extent.XMin, extent.YMin);
        //get the upper right corner of the extent
        var pointToCoordinates = new Coordinate2D(extent.XMax, extent.YMax);
        List<Coordinate2D> points = new List<Coordinate2D> { pointFromCoordinates, pointToCoordinates };
        //create the polyline
        var lineSegment = PolylineBuilderEx.CreatePolyline(points);
    
        //specify a symbol
        var line_symbol = SymbolFactory.Instance.ConstructLineSymbol(
                              ColorFactory.Instance.GreenRGB);
        //create a CIMGraphic 
        var graphic = new CIMLineGraphic()
        {
          Symbol = line_symbol.MakeSymbolReference(),
          Line = lineSegment,
        };
        graphicsLayer.AddElement(graphic);
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also