Sector over maps

Need help in implementing some specific function to your LightningChart Ultimate powered application? Post a question and get code snippets from other LightningChart Ultimate community members.

Moderator: Queue Moderators

Post Reply
SupportArchives
Posts: 16
Joined: Tue Mar 26, 2013 11:01 pm

Sector over maps

Post by SupportArchives » Thu Apr 25, 2013 4:31 pm

How to show a sector over a Maps?

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Sector over maps

Post by ArctionPasi » Thu Apr 25, 2013 4:38 pm

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.

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;


        } 
Then calling it

Code: Select all

CreateSector(20, 40, 50, -180, 135, 20);


produces a sector like this:
SectorOverMap.PNG
SectorOverMap.PNG (410.79 KiB) Viewed 9208 times
LightningChart Support Team, PT

Post Reply