Overriding styles, Featureoverridestylemodifiers – Pitney Bowes MapXtreme User Manual
Page 294

Chapter 15: Stylizing Your Maps
Overriding Styles
MapXtreme v7.1
301
Developer Guide
Overriding Styles
Styles can be permanently changed for features by saving the new style to the table. Styles for
features can also be changed for the current display (not permanent) by overriding the current style
For example, a ranged theme overrides the style of a region object to shade it. See
for more information.
Label styles can also be overridden. This section introduces you to the main style override class for
features. See more about features and labels in the chapter on the Mapping namespace
and
.
FeatureOverrideStyleModifiers
This class implements FeatureStyleModifier to override a feature’s style. Its Style property is a
composite style object that is used to specify what parts of a feature's style to override.
The contents of the style object passed to the Modify() method change dynamically for each feature
that is drawn. This increases the drawing speed of layers that contain style modifiers. It is therefore
important to make a copy of the style object if you need to use it elsewhere in your application. You
should also note that for the CompositeStyles in the Style Stack passed to the
FeatureStyleModifier.Modify() method, the Changed event does not fire.
Code Sample: FeatureOverrideStyleModifier
The following sample demonstrates how to use FeatureOverrideStyleModifier and layer
FeatureStyleModifiers to change styles of various features within a map.
In this snippet from the ChangeStyles sample application, we want to override the world capitals
layer with a single red symbol, but keep the point size.
VB example:
'Get the layer we want
Dim _lyr As FeatureLayer = Me.mapControl1.Map.Layers("worldcap")
'Create a sparse point style
Dim vs As MapInfo.Styles.SimpleVectorPointStyle = New _
SimpleVectorPointStyle
'Just change the color and code and attributes flag to indicate that
vs.Code = 55
vs.PointSize = 25
vs.Color = System.Drawing.Color.Red
' And apply to the layer
Dim fsm As FeatureOverrideStyleModifier = New _
FeatureOverrideStyleModifier(Nothing, New _
MapInfo.Styles.CompositeStyle(vs))
_lyr.Modifiers.Append(fsm)
Me.mapControl1.Map.Zoom = New MapInfo.Geometry.Distance(6250, _
MapInfo.Geometry.DistanceUnit.Mile)
End Sub