CreateNewFeatureLayer

The CreateNewFeatureLayer method enables you to create a new feature layer directly from TerraExplorer.

 

JavaScript

 

CreateNewFeatureLayer(

       layerName,

       LayerGeomType,

       sConnectionString,

       GroupID)

 

C#

 

IFeatureLayer65 CreateNewFeatureLayer(

       string        layerName,

       LayerGeometryType    LayerGeomType,

       string        sConnectionString,

       [string       lParentGroupID = ""])

 

C++

 

HRESULT CreateNewFeatureLayer(

        BSTR  layerName,

        LayerGeometryType   LayerGeomType,

        BSTR  sConnectionString,

        BSTR  GroupID,

        IFeatureLayer65 **  pILayer) 

 

Parameters

layerName

The name of the layer as it appears in the Project Tree.

LayerGeomType

An enum that determines the geometry type. The following are the possible LayerGeometryType values:

·          LGT_NONE = -1

·          LGT_POINT = 0

·          LGT_POLYLINE = 1

·          LGT_POLYGON = 2

·          LGT_COLLECTION = 3

sConnectionString

A string that specifies information about the layer data source and the means of connecting to it.

Note: Only a new Shape file can be created using this method. The connection string must include “TEPlugName=OGR” and “FileName=NameOfShapeFile.shp”.

GroupID

The Project Tree group in which the layer is created. If it is set to an empty string, the object is created under the root. You can obtain the GroupID by one of the following methods:

·          Create the group using IProjectTree65.CreateGroup.

·          Find the group, if you know the name, using IProjectTree65.FindItem.

·          Traverse the Tree using IProjectTree65 methods such as GetNextItem, until you come to the desired GroupID.

Return Value

pILayer 

An IFeatureLayer65, representing the newly created layer.

Exceptions

See: HRESULT Return Values for a list of possible values returned by the HRESULT.