Label in Polygon

Topics: Windows Forms
Jan 11, 2012 at 2:19 PM
Edited Jan 11, 2012 at 2:19 PM

Hello,

I need to put a label in the center of each polygon. As I can do this?

Thanks.

Coordinator
Jan 11, 2012 at 2:28 PM

create custom polygon and override OnRender

Jan 11, 2012 at 3:15 PM

You could give me an example of the above?

Coordinator
Jan 11, 2012 at 4:16 PM

class myPlogon : GMapPolygon
{
 public override void OnRender()
 {
   ...
 }

Jan 11, 2012 at 5:05 PM

But the OnRender() method don't exist :S.

class CustomPolygon : GMapPolygon
    {
        public CustomPolygon(List<PointLatLng> points, string name)
            : base(points, name)
        {
            
        }
        public override void OnRender(System.Drawing.Graphics g)
        {
            g.DrawString("Custom Text", new Font("Segoe UI", 10, GraphicsUnit.Pixel), new SolidBrush(Color.Red), 0, 0);
        }
    }

In "public override void OnRender(System.Drawing.Graphics g)" is presented in an error: Could not find any appropriate member to override.

The .dll file version is 1.6.0.0.

Thanks.

Coordinator
Jan 11, 2012 at 5:21 PM

try latest changeset

Jan 18, 2013 at 6:27 PM
Edited Jan 18, 2013 at 6:27 PM

I Tried This Code But always draws Label At the center of the map, how do you calculate the centroid of the Polygon?? 

Tks

Sep 4, 2013 at 11:29 AM
PointLatLng calculaCentroPoligono(List<PointLatLng> PuntosPoligono)
    {
        PointLatLng Centroide= new PointLatLng();
        int suma = 0;
        double Lat = 0;
        double Lng = 0;
        foreach (PointLatLng Punto in PuntosPoligono)
        {
            suma++;
            Lat += Punto.Lat;
            Lng += Punto.Lng;

        }
        Lat = Lat/suma;
        Lng = Lng/suma;

        Centroide.Lat=Lat;
        Centroide.Lng=Lng;

        return Centroide;
    }