Creating Client Applications

The COM interface is a standard method of communicating between applications. You can develop a client application that utilizes TerraExplorer COM capabilities by using scripting languages (e.g., JavaScript) in an HTML page or by using non-scripting languages (e.g., C++ or C#) in a stand-alone or DLL application. For creating a client application using embedded controls, see How to Work with ActiveX Controls.

Working with Scripting Languages

TerraExplorer interfaces can only be used in a web browser that supports ActiveX controls, i.e., only in Internet Explorer. Use the <OBJECT> tag to incorporate TerraExplorer in the web page and then use the object properties to get access to all main interfaces.

Javascript is an example of a scripting language that you can use to add the TerraExplorer COM capabilities to any HTML page. You can display this HTML page in one of TerraExplorer’s containers or in a separate web browser. SeeCreating an HTML Client Application” in the “Examples in JavaScript” chapter for an example of how to initialize SGWorld and create a basic HTML to which to add the TerraExplorer COM interfaces using JavaScript.

 

Follow these steps to create a Javascript client application using TerraExplorer interfaces:

1.      Define the TerraExplorer Object – Use the HTML Object tag to declare the object using TerraExplorer’s unique class id. 

<object id="SGWorld" classid="CLSID: 3A4F919F-65A8-11D5-85C1-0001023952C1" style="visibility:hidden;height:0 "></object>

2.      Access the main interfaces – The HTML Object exposes an ISGWorld74 interface. Using this interface you can access all the main TerraExplorer interfaces. For example, to zoom in you will need to call the INavigate74 ZoomIn method:

SGWorld.Navigate.ZoomIn();

 

Working with C#      

Using C# or any non-scripting language allows you to develop more complex and powerful client applications.

The instructions provided here refer to Microsoft Visual Studio 2017.

Follow these steps to create a C# client application using TerraExplorer Interfaces:

1.      Set Project References – From the Project menu, select Add Reference. Select the COM tab,  locate TerraExplorerX 1.0 Type Library from the available references, select its check box, and then click OK.

Note:     When a reference to a COM component is added to a .NET project an interop DLL is automatically created. You can find “Interop.TerraExplorerX.dll” in the obj folder of your project. This DLL intermediates between the COM and .NET components.

2.      Add Using directive – To access types in the TerraExplorerX namespace.

using TerraExplorerX;

3.      Define Variable for SGWorld Object – Declare an SGWorld variable.

private SGWorld74 sgworld;

4.      Create TerraExplorer Object – Use new to reference the variable to the SGWorld object.

this.sgworld = new SGWorld74();

5.      Access the main interfaces – Using this object you can access all the main TerraExplorer interfaces. For example to zoom in you will need to call the INavigate74 ZoomIn method:

sgworld.Navigate.ZoomIn();