Sector over maps
Moderator: Queue Moderators
-
- Posts: 16
- Joined: Tue Mar 26, 2013 11:01 pm
Sector over maps
How to show a sector over a Maps?
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Sector over maps
Use PolygonSeries and calculate the edge points.
The following method adds a red PolygonSeries in ViewXY, and calculates the edge points by using Sin and Cos.
Then calling it
produces a sector like this:
The following method adds a red PolygonSeries in ViewXY, and calculates the edge points by using Sin and Cos.
Code: Select all
void CreateSector(double centerLongitude,
double centerLatitude,
double radius,
double startAngle,
double sectorAngle,
int edgePointCount)
{
PolygonSeries polygon = new PolygonSeries(m_chart.ViewXY, m_chart.ViewXY.XAxes[0], m_chart.ViewXY.YAxes[0]);
polygon.Fill.GradientFill = GradientFill.Solid;
polygon.Fill.Color = Color.FromArgb(200, Color.Red);
m_chart.ViewXY.PolygonSeries.Add(polygon);
int iPointCount = edgePointCount +1; //1 is for center
PointDouble2D[] aPoints = new PointDouble2D[iPointCount];
aPoints[0] = new PointDouble2D(centerLongitude, centerLatitude);
for (int i = 0; i < edgePointCount; i++)
{
double dAngle = startAngle + (double)i * sectorAngle / (double)(edgePointCount-1);
double dAngleRad = dAngle / 180.0 * Math.PI;
aPoints[1 + i].X = radius * Math.Cos(dAngleRad) + centerLongitude;
aPoints[1 + i].Y = radius * Math.Sin(dAngleRad) + centerLatitude;
}
polygon.Points = aPoints;
}
Code: Select all
CreateSector(20, 40, 50, -180, 135, 20);
produces a sector like this:
LightningChart Support Team, PT