Maps for WinForms
凡例

マップ内での凡例は、マップが何を表示しているかを解釈するのに役立つ貴重な情報を提供します。 凡例は、データに基づいてさまざまな色や形で表すことができます。マップ内のベクター要素やマーカーについて説明する凡例を追加できます。

凡例は、MapLegend クラスを使用してマップに表示できます。凡例を追加したら、それに凡例項目を追加する必要があります。凡例項目は、MapLegendItem クラスを使用して表示できます。

次のコードを使用して、マップに凡例と凡例項目を追加してカスタマイズできます。

C#
コードのコピー
// マップのソースを追加します
c1Map1.TileLayer.TileSource = new VirtualEarthHybridSource();
// 凡例を追加します
var legend = new C1.Win.Map.MapLegend();
c1Map1.Legends.Add(legend);
legend.Alignment = ContentAlignment.TopRight;
legend.Margin = new Padding(0, 20, 20, 0);
legend.Padding = new Padding(5);
legend.Layout = MapLegendLayout.Column;
legend.Style.Border.Width = 1;
legend.Style.BackColor = Color.OldLace;
legend.Title.Caption = "LEGEND";
legend.Title.Position = DockStyle.Top;
legend.Title.Padding = new Padding(5);
legend.Title.Style.Alignment = ContentAlignment.MiddleCenter;
legend.Title.Style.Font = new Font("Arial", 12, FontStyle.Bold);
legend.Title.Style.ForeColor = Color.Black;
var item1 = new C1.Win.Map.MapLegendItem();
legend.Items.Add(item1);
item1.Label = "Item1";
item1.Kind = MapLegendItemKind.Marker;
item1.Shape = MarkerShape.Circle;
item1.Style.BackColor = Color.GreenYellow;
item1.Style.ForeColor = Color.Black;
var item2 = new C1.Win.Map.MapLegendItem();
legend.Items.Add(item2);
item2.Kind = MapLegendItemKind.Rectangle;
item2.Label = "Item2";
item2.Style.ForeColor = Color.Black;
item2.Size = new SizeF(20, 20);
item2.Style.Alignment = ContentAlignment.MiddleLeft;