My "AddMyPolygon()" method not working

Mar 11, 2010 at 11:32 PM

Hello there,

I'm trying to write my own method to add a polygon on the map. I called it AddMyPolygon and added into public class VEMap. I used a code found on this forum.

Unfortunately, the code does nothing. I need a simple piece of code to add a polygon on my map (WPF VS10 application). I am using InfoStrat v2.1.0.0.

Here is the code:

public void AddMyPolygon()
   this.globeControl.Host.Geometry.RemoveGeometry("My Layer", "SelBox");

   LatLonAlt[] points = new LatLonAlt[4]; 
   points[0] = new LatLonAlt(43.5072604512174, 16.4415222034725, 0);
   points[1] = new LatLonAlt(16.4415222034725, 43.5072604512174, 0);
   points[2] = new LatLonAlt(18.4415222034725, 45.5072604512174, 0);
   points[3] = new LatLonAlt(45.5072604512174, 18.4415222034725, 0); 

   var style = PolyInfo.DefaultPolygon;

   style.LineWidth = 2;
   style.LineColor = System.Drawing.Color.FromArgb(255, 0, 01);
   style.Filled = false;
   style.DashStyle = Microsoft.MapPoint.Rendering3D.Utility.DashStyle.DashDot;

   this.globeControl.Host.Geometry.AddGeometry(new PolygonGeometry("My Layer", "SelBox", this, points, PolygonGeometry.PolygonFormat.Polygon2D, style));
Mar 18, 2010 at 9:18 AM

Hello Nebo,

There is a bit more options you need to add to your style object perhaps, just give a try to that:

Here is the method I have been using inside myVEMap.cs class file inside InfoStrat.VE project:

public void AddShape(VEShape shape, string layerId)
    if (shape.ShapeType == VEShapeType.Polyline)
        List<LatLonAlt> lla = new List<LatLonAlt>();

        foreach (VELatLong item in shape.Points)
        PolyInfo polylineStyle = PolyInfo.DefaultPolygon;
        polylineStyle.AltitudeMode = AltitudeMode.FromGround;
        polylineStyle.LineHighlightColor = System.Drawing.Color.DarkBlue;
        polylineStyle.FillColor = System.Drawing.Color.FromArgb(120, System.Drawing.Color.Blue);

        PolygonGeometry geom = new PolygonGeometry(
        layerId, Guid.NewGuid().ToString(), null,
        lla.ToArray(), PolygonGeometry.PolygonFormat.Polygon2D,



Mar 26, 2010 at 6:11 AM

Thanks for helping out with the code sample Ben.