Buy Now 

Free Trial




Maptitude Mapping Software

Development in Microsoft Office VB and VBA (Visual Basic for Applications) and COM (Component Object Model)

Accessing Maptitude as a COM Object

GISDK provides an environment for accessing GISDK functions in a variety of ways. Using Caliper Script, you can write add-ins or custom applications composed of GISDK macros that call GISDK functions. These add-ins or custom applications are run from within Maptitude.

GISDK also allows you to call GISDK functions and macros from another application, written in another programming language such as Visual Basic. You do this using COM. Maptitude is accessed as a COM Object, which can provide map, data, and geographic analysis services. You write your application in a programming language that can make COM calls, and when you need map services you call the Maptitude object to supply those services.

You can call GISDK functions directly, or you can call GISDK macros, compiled in a UI Database, that call GISDK functions. Calling GISDK functions directly is good for simple operations, while using GISDK macros is helpful when doing more complex or frequently needed operations.

The COM model is designed so that clients have access to the full range of Caliper Script functions through the main Maptitude object. This object includes the methods for calling GISDK functions and macros with the necessary arguments.

The subsidiary MacroVal object provides a wrapper for the custom compound types that are used by many of the GISDK functions.


It is possible to work with GISDK classes from VBA. Maptitude provides a COM interface for accessing the GISDK via VBA and other COM client applications. This is documented in the Maptitude Help under the topic, "Accessing Maptitude as a COM Object" described above.

The CreateObject method requires a 2nd parameter, which is the path to the compiled GISDK user interface (UI) database which contains the class. Often the standard Maptitude UI database is referenced, and in the case this 2nd value can just be the empty string.

You can then use the COM methods named Get, Set and Method to get and set properties and call methods on the GISDK object from VBA.

Here is an example of how you would work with the Routing API:

Set Gisdk = CreateObject("Maptitude.AutomationServer")

coords = Array(Gisdk.Function("Coord", -71206120, 42321660), _
     Gisdk.Function("Coord", -71208932, 42349258))

Set router = Gisdk.CreateObject("Routing.Router", "")
router.Set "Minimize", "Distance"
Set path = router.Method("CalculatePath", coords)

How To

From VBA, you would use the References dialog ( ) to add a reference to the Maptitude Type Library. You can then use all the functionality of the Maptitude Automation Server API to work with Maptitude functionality. The example that we ship in GISDK\Samples\ACTIVEX is most applicable to this scenario.

If you were developing a Microsoft Access add-in in a .NET language, then you could alternatively use the CaliperForm API (moreā€¦).

For More Information:

The Maptitude GISDK Help also contains detailed information on accessing Maptitude as a COM object

Programming Examples:

Below is one complete VBA example.

Begin VB.Form Client
  Begin VB.TextBox TownName 
      Appearance      =   0  'Flat'
      Height          =   372
      Left            =   120
      TabIndex        =   0
      Top             =   480
      Width           =   2892
   Begin VB.CommandButton GetMap 
      Appearance      =   0  'Flat'
      Caption         =   "&Get Map"
      Default         =   -1  'True'
      Height          =   372
      Left            =   3120
      TabIndex        =   2
      Top             =   480
      Width           =   1092

Private Sub Form_Load() 
     Set Gisdk = CreateObject("Maptitude.AutomationServer")
     Gisdk.RunMacro "MinimizeWindow", "Frame|"
     Gisdk.RunMacro "SetMapUnits", "Miles"
     ' Open the map used by this application '
     Gisdk.RunMacro "OpenMap", "gisdk\samples\activex\", Null
     ' Change its size to the size required by the client '
     Gisdk.RunMacro "SetWindowSizePixels", Null, 340, 270
     ' Change the current layer to the cities and towns layer '
     Gisdk.RunMacro "SetLayer", "Cities & Towns"
End Sub 

Private Sub GetMap_Click()
     ' Convert the town_name to upper case '
     town_name = UCase(TownName.Text)
     ' Locate the town specified by the client '
     Dim srch_value(1 To 1)
     srch_value(1) = town_name
     rh = Gisdk.RunMacro("LocateRecord", "Cities & Towns|", "[City Name]", srch_value, Null)
     If IsNull(rh) Then GoTo no_town       'No matching record was found'
     ' Read the name of the town located '
     layer = "Cities & Towns"
     Dim fldnm(1 To 1)
     fldnm(1) = "City Name"
     info = Gisdk.RunMacro("GetRecordValues", layer, rh, fldnm)
     found_name = info(1)(2)
     ' Check that the name matches the name requested '
     If Mid(found_name, 1, Len(town_name)) <> town_name Then GoTo no_town
     ' Zoom to that town '
     Set scp = Gisdk.RunMacro("GetRecordScope", rh)
     scp.Width = 15.1    'miles'
     scp.Height = 15.1   'miles'
     Gisdk.RunMacro "SetMapScope", Null, scp
     Gisdk.RunMacro "RedrawMap", Null
     ' Copy the map to the clipboard '
     Gisdk.RunMacro "CopyMapToClipboard", Null, Null
     ' Show the name of the located town in the edit text '
     TownName.Text = found_name
     ' Copy the map off the clipboard '
     Bitmap.Picture = Clipboard.GetData(CF_BITMAP)
     Exit Sub 
     MsgBox ("Town not found.")
     Exit Sub
     End Sub 
End Sub