User Tools

Site Tools


api:dk11:delphi:gisviewer.tgis_viewer.add_tgis_layerabstract

TGIS_Viewer.Add method

DK11 for Delphi | GisViewer.TGIS_Viewer.Add | Constructors | Fields | Methods | Properties | Events

Add a layer to the Viewer.

Available also on: .NET | Java | ActiveX | Python.

Syntax

Implements IGIS_Viewer.Add.

// Delphi
public
  procedure Add(
    const _layer : TGIS_LayerAbstract
  );
// C++ Builder
public:
  void Add(
    TGIS_LayerAbstract* const _layer
  );

Parameters

Name Type Description
_layer TGIS_LayerAbstract layer to be added

Remarks

Use this method to add a new custom layer to the viewer. For some layers (on-disk) it's recommended to assign a layer extent earlier to avoid its recalculation.

Example

Delphi

procedure MyClass.AddLayer ();
var
  myExtent : TGIS_Extent;
  shpType : TGIS_ShapeType;
  myLayer : TGIS_LayerSHP;
  layerName : String;
  layerPath : String;
  layerFullName : String;
begin
  // Set the extent of the new layer
  myExtent:=GIS.Extent;
 
  // Set type of the shape
  shpType:=TGIS_ShapeType.Polygon;
 
  // Set a name for a layer to be created.
  layerPath := GetFilePath(Application.ExeName);
  layerName := 'Layer_'+IntToStr(GIS.Items.Count+1)+'.shp';
  layerFullName:=layerPath + layerName;
 
  // Create a new layer.
  myLayer:=TGIS_LayerSHP.Create ;
 
  // Build layer file and set the layer path and name.
  myLayer.Build (layerFullName, myExtent, shpType);
  myLayer.Path:=layerFullName;
  myLayer.Name:=layerName;
 
  // Add layer to the viewer.
  GIS.Add (myLayer);
end ;

References

2022/11/30 19:19

Page Tools