CreateFeatureLayer

CreateFeatureLayer loads a feature layer into the project. A feature layer is a visual representation of a geographic data set like roads, national parks, political boundaries, and rivers using geographic objects such as points, lines, and polygons and optional corresponding annotation objects.

TerraExplorer enables you to load feature layers from remote or local databases. Various file formats are supported through a set of external plug-ins. SeeFeature Layer Connection Strings” for a list of the supported connection string values and parameters. You are always connected to the data source (local or remote), and all changes to the feature layers can be saved to the original source file. You can get the latest updates to a layer source by refreshing the layer.

TerraExplorer handles differently layers that are created by loading native feature sources (Shapefiles, GeoPackage, GeoDatabase, PDF or SQLite file files, and all server inputs) and layers that are created by loading non-native feature files (e.g., DXF, ASCII and OpenFlight files). For the former, a layer object containing the geographic objects is created in the Project Tree while for the latter the geographic objects are read and put in the TerraExplorer Project Tree as a Group.

If the source file coordinate system is not the same as the MPT file Terrain Coordinate system, you can reproject it using the IFeatureLayer80.Reproject method.

CreateFeatureLayer only loads a feature layer into the project. If you want to load the new layer on the terrain, use the IFeatureLayer80.Load method.

This method executes synchronously, meaning it returns after the layer is created. If you want to execute asynchronously, use CreateFeatureLayerAsync instead.

 

JavaScript

 

CreateFeatureLayer(

       layerName,

       sConnectionString,

       GroupID)

 

C#

 

IFeatureLayer80 CreateFeatureLayer(

       string        layerName,

       string        sConnectionString,

       string        GroupID = "")

 

C++

 

HRESULT CreateFeatureLayer(

       BSTR   layerName,

       BSTR   sConnectionString,

       BSTR   GroupID,

       IFeatureLayer80 ** pILayer) 

Parameters

layerName

A string representing the name of the layer.

sConnectionString

Specifies information about the data source and the means of connecting to it. SeeFeature Layer Connection Strings” for a list of the supported connection string values and parameters.

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 IProjectTree80.CreateGroup.

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

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

Return Value

pILayer

An IFeatureLayer80, representing the newly created layer. This method executes synchronously, meaning it returns after the layer is created. If you want to execute asynchronously, use CreateFeatureLayerAsync instead.

Exceptions

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