Label priorities, Label layer selectability, Code example: creating a labellayer – Pitney Bowes MapXtreme User Manual

Page 249

Advertising
background image

Chapter 12: Adding Mapping Capability to Your Applications

Labels

MapXtreme v7.1

256

Developer Guide

Label Priorities

Label priorities determine which labels within the same LabelLayer are generated when either
AllowOverlap or AllowDuplicates is set to False. Note: as stated in

Generating Labels

, each label

layer is independent of each other, so different overlap or duplicate settings in other layers do not
factor in here.

When a label overlaps with or is a duplicate of another label in the same layer, the priorities of both
labels are compared to determine which label to keep. The process first compares the priority of
each label (known as the inter-label source). The label with higher priority is kept.

MapXtreme provides two levels of priorities for controlling the display of labels: Major and Minor.
This allows you to group and subgroup prioritization. For example, you might want cities with large
populations to have labels with a higher priority than small towns. However, you can also add a
modifier to bump up the major priority of one small town to give it a chance over the major cities.

When the Major priority is set to null (nothing in Visual Basic), the value used is the inverse of the
label's LabelSource position within a LabelLayer. The higher the index position the lower the priority.
For example, if a LabelSource is at index 3 and there are 10 LabelSources (indices from 0 to 9), the
Major priority will be 6 (the inverse of the index based on total).

When the Minor priority is set to null (Nothing in Visual Basic), the value used is based on the Key of
the Feature being labeled. The inverse of a numeric representation of the key against the number of
rows in the Table is used. For example, if there are 10 rows in the Table, the minor priority of the
label for feature in row ID 7 defaults to 3 (10 - 7 = 3). If the key is not numeric the minor priority
defaults to 0.

When Major priorities are equal, the label with the higher Minor priority is kept.

To create a priority, use an expression that results in a numeric value. For example, the expression
in C# that results in a numeric value could be a field of numeric type or an expression like the ASC
value of the first letter in the field's value:

"(1/Asc(Country))*1e6"

Label Layer Selectability

To control selectability of label layers, use the SelectMapToolProperties.LabelsAreEditable property
programmatically or via Workspace Manager’s Labels are Editable checkbox.

The LayerHelper.SetSelectable method does not affect the selectability of certain layer types,
including Labels, WMS/WFS, Raster and Group layers.

Code Example: Creating a LabelLayer

The following example demonstrates the use of the classes associated with Labels.

VB example:

' Open usa table using the data catalog
Dim table As Table = Session.Current.Catalog.OpenTable("usa.tab")

' Create a new map

Advertising