Maptitude GISDK Help |
The example located in the folder GISDK\Samples\DotNet under the Maptitude program folder demonstrates how to access the GISDK environment from a console application. The Maptitude .NET classes are stored in CaliperForm.dll. The file is stored in the Code Samples folder as C:\Users\[Username]\Documents\Caliper\Maptitude YYYY\CodeSamples, where YYYY is the year of your Maptitude version and [Username] corresponds to the name assigned to the current user’s account
Here is an example of how to use CaliperForm.dll in a C# console project.
Use Visual Studio to create a C# console project.
Add a reference to CaliperForm.dll by choosing References>Browse and browse for the DLL in Documents\Caliper\Maptitude YYYY\CodeSamples\CaliperForm.dll..
Replace the contents of the automatically generated Program.cs file, by copying the contents of Program.cs in the GISDK\API\Dotnet folder.
You now have a sample .NET console program that you can compile and test.
The example illustrates in a nutshell how to access GISDK data from a .NET application. The example opens a connection to the GISDK environment, opens a map, and closes the connection to the GISDK environment:
using System;
using System.Collections.Generic;
using System.Text;
using CaliperForm;
///
/// Open a map in the tutorial folder, and list its content.
///
static void Open_Map() {
CaliperForm.Connection Conn = new CaliperForm.Connection
{ MappingServer = "Maptitude" };
Boolean opened = false;
try {
opened = Conn.Open();
if (opened) {
// You must declare dk as "dynamic" or the compiler will throw an error
dynamic dk = Conn.Gisdk;
string tutorial_folder = dk.Macro("G30 Tutorial Folder") as string;
// Obtain information about Conn: an array of [ "program_path" , "program
// name" , "program type" , build number (integer) , version number (real) ,
// instance number ]
Object[] program_info = dk.GetProgram();
string program_name = program_info[1] as string;
int build_number = (int)program_info[3];
double version_number = (double)program_info[4];
// Set the path that will be used to look for layers used in map files
string search_path = "c:\\ccdata\\USA (HERE) - 2023 Quarter 4;d:\\ccdata";
dk.SetSearchPath(search_path);
// Open a map file in the tutorial folder
string map_file = tutorial_folder + "BestRout.map";
var map_options = new OptionsArray();
// you can also use Dictionary or Hashtable
map_options["Auto Project"] = "true";
string data_directory = System.IO.Path.GetDirectoryName(map_file);
map_options["Force Directory"] = data_directory;
// path used to look for layers used in the map
string map_name = dk.OpenMap(map_file, map_options) as string;
if (map_name == null) {
Console.Out.WriteLine("Cannot open map " + map_file +
". Perhaps some layers cannot be found?");
return;
} else {
Console.Out.WriteLine("map_name = " + map_name);
}
// Set the current layer
dk.SetLayer("County");
// Get information about the list of layers contained in this map
dynamic layers = dk.GetMapLayers(map_name, "All");
dynamic layer_names = layers[0];
int current_idx = (int)layers[1];
string current_layer = layers[2] as string;
dk.CloseMap(map_name);
Conn.Close();
}
} catch (System.Exception error) {
Console.Out.WriteLine(error.Message);
}
}
For more information, see:
Getting Started with CaliperForm
Using the CaliperForm.Connection Class
Using the GISDK Extension Engine In-Process API
See also these specific C# examples for:
©2025 Caliper Corporation | www.caliper.com |