CreateLegend()
Summary
Creates a map legend.
Changes
In Version 5.0 added Locked option.
Syntax
CreateLegend (string map_name, array settings, array options)
| Argument |
Contents |
| map_name |
The name of the map |
| settings |
Required information about the legend (see table below) |
| Settings Element |
Type |
Contents |
| 1 |
String |
Type of legend ("Automatic", "Manual", or "None", where "None" creates a legend based on the given settings and options but does not display it) |
| 2 |
Array |
Six flags indicating the legend contents (see table below) |
| 3 |
Array |
Three flags indicating legend style (see table below) |
| 4 |
Array |
Four font strings indicating the font to use for the legend title, footnote, subtitles, and items |
| 5 |
Array |
Two strings containing the legend title and footnote |
| Contents Flags |
Type |
Contents |
| 1 |
Integer |
Whether to display a title (1 or 0) |
| 2 |
Integer |
Whether to display a footnote (1 or 0) |
| 3 |
Integer |
Whether to display layer information (1 or 0) |
| 4 |
Integer |
Whether to display set information (1 or 0) |
| 5 |
Integer |
Whether to display theme information (1 or 0) |
| 6 |
Integer |
How to display the scale of miles (0 for none, or 1-6 indicating the style to use) |
| Style Flags |
Type |
Contents |
| 1 |
Integer |
Whether the legend is attached to the map or in a separate window (1 or 0) |
| 2 |
Integer |
Whether the legend is framed (1 or 0) |
| 3 |
Integer |
Whether the background is filled (1) or transparent (0). If the background is filled (the default), a background style and background color must be specified as options in the options array |
| Option |
Type |
Contents |
| Layer Subtitle |
String |
Text for the layer information subtitle (defaults to "Map Layers") |
| Click Macro |
String |
Macro to run when the user double-clicks on a legend that is in its own window (use annotation handling for legends that are attached to the map) |
| Background Color |
Color |
Color of the legend background |
| Background Style |
Fillstyle |
Fill style of the legend background |
| Border Color |
Color |
Color of the legend frame |
| Border Style |
Linestyle |
Line style of the legend frame |
| Border Width |
Integer |
Width of the legend frame |
| Title Color |
Color |
Color of the title font |
| Footnote Color |
Color |
Color of the footnote font |
| Headings Color |
Color |
Color of the headings (subtitles) font |
| Standard Color |
Color |
Color of the standard (items) font |
| Scale Color |
Color |
Color of the scale bar |
| Columns |
Integer |
Number of legend columns (default=1) |
| Column Order |
String |
"Rows" to order items across rows or "Columns" to order items down columns |
| Locked |
Boolean |
If "True" the close box on legends in a separate window is disabled; the default is "False" |
Notes
-
If the legend is attached to a map and not in a separate window, it is a freehand item and can be moved or edited in the same way as other freehand items.
-
Items in an automatic legend are shown in their map display order. To change the order of legend items, change their display order in the map.
Example
CreateLegend("My Map", {"Automatic",
{1, 1, 0, 0, 0, 4},
{1, 1, 1},
{"Arial|16", "Arial|14", "Arial|Italic|12", "Arial|12"},
{"This is My Legend", "This legend created with GISDK"}
},)
Error Codes
| Error Type |
Meaning |
| Error |
The settings array does not have the correct number of items, or one of the items or options is invalid |
| NotFound |
The named map does not exist |
See Also