Legends, Scalebar adornment, Legends scalebar adornment – Pitney Bowes MapXtreme User Manual
Page 251

Chapter 12: Adding Mapping Capability to Your Applications
Adornments
MapXtreme v7.1
258
Developer Guide
Legends
Legends are for use in conjunction with themes. See
Chapter 14: Using Themes and Legends
more information about themes. Legends are created using the LegendFactory class. A Legend
consists of one or more legend frames. Each frame is either a ThemeLegendFrame or a
CartographicLegendFrame. Both kind of LegendFrames are created by using the
LegendFrameFactory class from the created Legend object. For manipulation and customization of
legends and their frames, use classes in the MapInfo.Mapping.Legends namespace. Classes in this
namespace include: CartographicLegendFrame, ThemeLegendFrame, LegendFormat,
LegendControl, and others.
You can set the size of the Legend with the Legend.Size property, but you cannot set the size of the
LegendFrames. The size of the LegendFrame is controlled by the amount of data it contains.
VB example:
Private Sub Page_Load(ByVal sender As Object, ByVal e As _
System.EventArgs)
LegendControl1.Map = MapControl1.Map
If Not IsPostBack Then
Dim normalLyr() As MapInfo.Mapping.LayerType = New _
MapInfo.Mapping.LayerType(1) {}
normalLyr(0) = MapInfo.Mapping.LayerType.Normal
Dim filter As MapInfo.Mapping.IMapLayerFilter = _
MapInfo.Mapping.MapLayerFilterFactory.FilterByLayerType(normalLyr)
Dim frame As MapInfo.Mapping.Legends.LegendFrame
Dim NewLegend As MapInfo.Mapping.Legends.Legend = _
MapControl1.Map.Legends.CreateLegend(New System.Drawing.Size(5, 5))
NewLegend.Format.FrameAlignment = _
MapInfo.Mapping.Legends.LegendFrameAlignment.Horizontal
Dim ftrLayer As MapInfo.Mapping.FeatureLayer
For Each ftrLayer In _
MapControl1.Map.Layers.GetMapLayerEnumerator(filter)
frame = _
MapInfo.Mapping.Legends.LegendFrameFactory.CreateCartographic_
LegendFrame(ftrLayer)
NewLegend.Frames.Append(frame)
Next
LegendControl1.Legend = NewLegend
Else
LegendControl1.Legend = MapControl1.Map.Legends(0)
End If
End Sub
ScaleBar Adornment
A scale bar is linear object used to measure map distances in the units of the map (such as
kilometers or feet). Use the ScaleBarAdornment class to create a ScaleBarAdornmentControl and
add the control to the map. If you attempt to add a ScaleBarAdornment to the map itself, it does
display, but without the ScaleBarAdornmentControl, the ScaleBar is not linked to the map itself.
VB example: