Ilabelsourcefilter, Labelproperties, Generating labels – Pitney Bowes MapXtreme User Manual

Page 248

Advertising
background image

Chapter 12: Adding Mapping Capability to Your Applications

Labels

MapXtreme v7.1

255

Developer Guide

ILabelSourceFilter

This interface allows you to enumerate through the collection of LabelSource objects in a
LabelLayer filtering on specific rules. You can also implement this interface to define your own
filtering rules.

LabelProperties

This class has label property information, such as style, positioning, etc. It supports the
representation of sparse label properties. This is very useful when using a LabelModifier to modify
only a portion of the label properties. This class also allows you to set prioritization and improved
placement of labels.

Generating Labels

The LabelLayer class generates labels when the map draws or when you call the
LabelLayer.Refresh method. Each visible label source is considered. You can have more than one
layer of labels in a map.

To generate a label for each feature in the source's table that is within current map view, the
LabelLayer class does the following:

1. Uses the DefaultLabelProperties property as the starting set of properties used to build the label.

2. Calls the Modify method of each visible label modifier in the Modifiers collection, if any. This

allows each modifier the opportunity for changing the label properties used to build the label.

3. Performs visibility constraint checks to decide whether to keep the label.

a. Checks for label visibility by comparing the visibility constraints against the current map

zoom/scale.

b. If the label is visible and overlaps and duplicates are not allowed on this label, checks for

overlap and duplicates against other existing labels. If any are found, uses

Label Priorities

to decide which label to keep.

4. Adds the label to the generated labels collection if it succeeds visibility constraints.

Note that Label generation rules only apply within each label layer and not the entire map. For
example, if you set the AllowOverlap property to False in all label sources contained within all the
label layers in a map, labels from one label layer will still overlap with labels from another label layer
because the labels are generated independently between label layers.

Use the LabelLayer.Refresh method if the map has not yet drawn to generate the labels based on
the current map view.

Accessing Generated Labels

You can access generated labels through the LabelSource.Labels property. This collection
represents the labels that are within the current map view. They do not represent all the labels in the
map. The items in the collection change as the view of the map changes.

Advertising