DK11 for Delphi | GisViewer.TGIS_Viewer.Add | Constructors | Fields | Methods | Properties | Events
Add a layer to the Viewer.
Implements IGIS_Viewer.Add.
// Delphi public procedure Add( const _layer : TGIS_LayerAbstract );
// C++ Builder public: void Add( TGIS_LayerAbstract* const _layer );
Name | Type | Description |
---|---|---|
_layer | TGIS_LayerAbstract | layer to be added |
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.
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 ;