[DEVEXPRESS/WINFORM] ChoroplethColorizer 클래스 : 수동으로 추가된 도형을 색상 표시하기
DevExpress/WinForm 2020. 6. 20. 18:50728x90
반응형
728x170
▶ MainForm.cs
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.Utils;
using DevExpress.XtraEditors;
using DevExpress.XtraMap;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : XtraForm
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
#region 툴팁 컨트롤러를 설정한다.
ToolTipController toolTipController = new ToolTipController();
toolTipController.AllowHtmlText = true;
#endregion
#region 맵 컨트롤을 설정한다.
MapControl mapControl = new MapControl();
mapControl.Parent = this;
mapControl.Dock = DockStyle.Fill;
mapControl.ToolTipController = toolTipController;
#endregion
#region 맵 항목 저장소를 설정한다.
MapItemStorage mapItemStorage = new MapItemStorage();
mapItemStorage.Items.Add
(
GetMapPolygon
(
800,
"Small triangle",
new GeoPoint[]
{
new GeoPoint(0 , 0 ),
new GeoPoint(0 , 40),
new GeoPoint(40, 0 ),
new GeoPoint(0 , 0 )
}
)
);
mapItemStorage.Items.Add
(
GetMapPolygon
(
1800,
"Large triangle",
new GeoPoint[]
{
new GeoPoint( 0 , 0 ),
new GeoPoint( 0 , -60),
new GeoPoint(-60, 0 ),
new GeoPoint( 0 , 0 )
}
)
);
#endregion
#region 도형 어트리뷰트 값 공급자를 설정한다.
ShapeAttributeValueProvider shapeAttributeValueProvider = new ShapeAttributeValueProvider();
shapeAttributeValueProvider.AttributeName = "AreaValue";
#endregion
#region CHOROPLETH 색상화기를 설정한다.
ChoroplethColorizer choroplethColorizer = new ChoroplethColorizer();
choroplethColorizer.ValueProvider = shapeAttributeValueProvider;
choroplethColorizer.RangeStops.AddRange
(
new List<double>
{
0,
1000,
2000
}
);
choroplethColorizer.ColorItems.AddRange
(
new List<ColorizerColorItem>
{
new ColorizerColorItem(Color.Yellow),
new ColorizerColorItem(Color.Red )
}
);
#endregion
#region 벡터 항목 레이어를 설정한다.
VectorItemsLayer vectorItemsLayer = new VectorItemsLayer();
vectorItemsLayer.Data = mapItemStorage;
vectorItemsLayer.Colorizer = choroplethColorizer;
mapControl.Layers.Add(vectorItemsLayer);
#endregion
#region 색상 스케일 레전드를 설정한다.
ColorScaleLegend colorScaleLegend = new ColorScaleLegend();
colorScaleLegend.Header = "Area";
colorScaleLegend.Layer = vectorItemsLayer;
mapControl.Legends.Add(colorScaleLegend);
#endregion
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region 맵 다각형 구하기 - GetMapPolygon(areaValue, polygonName, pointArray)
/// <summary>
/// 맵 다각형 구하기
/// </summary>
/// <param name="areaValue">영역 값</param>
/// <param name="polygonName">다각형 명칭</param>
/// <param name="pointArray">포인트 배열</param>
/// <returns>맵 다각형</returns>
private MapPolygon GetMapPolygon(double areaValue, string polygonName, GeoPoint[] pointArray)
{
MapPolygon mapPolygon = new MapPolygon();
mapPolygon.Attributes.Add
(
new MapItemAttribute()
{
Name = "AreaValue",
Type = typeof(double),
Value = areaValue
}
);
mapPolygon.Attributes.Add
(
new MapItemAttribute()
{
Name = "PolygonName",
Type = typeof(string),
Value = polygonName
}
);
mapPolygon.ToolTipPattern = "{PolygonName}=<b>{AreaValue}</b>";
foreach(GeoPoint point in pointArray)
{
mapPolygon.Points.Add(point);
}
return mapPolygon;
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'DevExpress > WinForm' 카테고리의 다른 글
[DEVEXPRESS/WINFORM] MapBubble 클래스 : 맵 버블 항목 수동으로 추가하기 (0) | 2020.06.20 |
---|---|
[DEVEXPRESS/WINFORM] MapOverlay 클래스 : 지도 상에 부가 정보 표시하기 (0) | 2020.06.20 |
[DEVEXPRESS/WINFORM] IClusterer 인터페이스 : 커스텀 Clusterer 구현하기 (0) | 2020.06.20 |
[DEVEXPRESS/WINFORM] IClusterItemFactory 인터페이스 : 벡터 항목 집계하기 (0) | 2020.06.20 |
[DEVEXPRESS/WINFORM] GraphColorizer 클래스 : 윤곽선 색상 표시하기 (0) | 2020.06.20 |
[DEVEXPRESS/WINFORM] PieChartDataAdapter 클래스 : 차트 항목 자동으로 생성하기 (0) | 2020.06.20 |
[DEVEXPRESS/WINFORM] ListSourceDataAdapter 클래스 : 데이터 소스에서 벡터 항목을 자동으로 생성하기 (0) | 2020.06.19 |
[DEVEXPRESS/WINFORM] SvgFileDataAdapter 클래스 : SVG 파일에서 데이터 로드하기 (0) | 2020.06.19 |
[DEVEXPRESS/WINFORM] KmlFileDataAdapter 클래스 : KML 파일에서 데이터 로드하기 (0) | 2020.06.19 |
[DEVEXPRESS/WINFORM] ShapefileDataAdapter 클래스 : 도형 파일에서 데이터 로드하기 (0) | 2020.06.19 |
댓글을 달아 주세요