Using MapViewer Objects

 

To access MapViewer commands from your script you must create a MapViewer Application object. To create an Application object, call the CreateObject function with " MapViewer.Application" as the argument.

 

Every object has properties and methods associated with it. Properties are values describing the state of an object. Methods are actions an object can perform. Access properties and methods by typing the name of an object variable, followed by a period, followed by the property or method name.

 

You can use object properties as you would use variables: assign values to properties, branch based on the value of a property, or use the value of a property in calculations. You call an object's methods as you would call subroutines and functions. Use the return values from methods the same as you would use return values from functions.

 

When you "drill through" the object hierarchy, you can store references to intermediate objects in variables, or you can string together long sequences of object references. For example, you can set the default font for a map document in a single line:

' Assume " mvApp" is a variable holding a reference to the Application object

mvApp.Documents.Item(1). DefaultFont.Bold = True

 

Alternatively, you can store each intermediate object in variables as you traverse the object hierarchy:

' Assume " mvApp" is a variable holding a reference to the Application object

Set docs = mvApp.Documents

Set plot = docs.Item(1)

Set font = plot.DefaultFont

font.Bold = True

 

The second form - storing intermediate objects - is more efficient if you are performing several actions with the same object. A third alternative is to use the WITH…END WITH statement:

' Assume " mvApp" is a variable holding a reference to the Application object

With mvApp.Documents.Item(1). DefaultFont

.Bold = True

.Size = 12

.Color = mvColorRed

End With

 

 

See Also

MapViewer Object Model

Overview of MapViewer Objects

Derived Objects

Using Collection Objects

Parent and Application Properties

Optional Arguments

Object Hierarchy

Object List