Maptitude GISDK Help |
Here is an example that uses several types of window macros. This macro creates two map windows and one editor window, tiled on the screen. When you activate either map, the activate macros set the current layer to be the first area layer in the map. When either map window is closed, the close macros display a message. When you click in an editor, a message displays the number of highlighted cells.
// This macro creates three windows
Macro "set things up"
// open the first map file
folder = RunMacro("G30 Tutorial Folder")
map1 = OpenMap("folder + "bestrout.map",
{
{"Activate Macro", "activate map"}, // runs when window is activated
{"Close Macro", "close map 1"} // runs when window is closed
})
// open a second map file
map2 = OpenMap("folder + "manh_zip.map",
{
{"Activate Macro", "activate map"}, // and the same activate macro
{"Close Macro", "close map 2"} // and a different close macro
})
// open a dataview file
ed1 = OpenEditor("folder + "calculat.dvw", null)
// set a highlight macro
SetEditorOption(ed1, "Highlight Macro", "check editor highlight")
TileWindows() // arrange windows side-by-side
endMacro
// Here are the other macros:
// This macro runs when ANY map is activated
Macro "activate map"
lyr_info = GetMapLayers( , "Area") |
// Get info on area layers in current map |
first_layer = lyr_info[1][1] |
// Read the name of the first area layer |
SetLayer(first_layer) |
// Make that layer current |
endMacro
// This macro runs when the first map is closed
Macro "close map 1"
ShowMessage("Your first map is about to close!") |
// Display a message or two... |
ShowMessage("The current layer is " + GetLayer()) |
|
Return(null) |
// The map window closes... |
endMacro
// This macro runs when the second map is closed
Macro "close map 2"
ShowMessage("Your second map is about to close!") |
// A different message... |
ShowMessage("The current layer is " + GetLayer()) |
|
Return(null) |
// The map window closes... |
endMacro
// This macro runs whenever the highlighted cells in the editor change
Macro "check editor highlight"
tmp = GetEditorHighlight() |
// read the size of the highlighted area |
if tmp = null then ShowMessage("You didn't highlight anything!")
else if tmp[1] = null then ShowMessage("You highlighted a row!")
else if tmp[2] = null then ShowMessage("You highlighted a column!")
else do
ncells = String(tmp[1].length * tmp[2].length)
ShowMessage("You highlighted " + ncells + " cells!")
end
endMacro
©2025 Caliper Corporation | www.caliper.com |