This project is read-only.

Draw polygon and point marker in the same shapefile

May 23, 2015 at 7:11 AM
hello everyone,
am new user of mapwingis working with c# and i woud like to perform the following actions on the map:
1) draw 4 Pathlines from coordinates :
  • each pathline is a polygon with different color and a bunch number of waypoints as markers
  • each waypoint of pathline has a different marker (icon+waypoint index), all waypoints of all pathlines uses the same icon, only the index is variable and it is drawn on icon.
  • each pathline(polygon + waypoints) is stored in one shapefile.
    2) the possibility of hiding and displaying each Pathline (as user wish)
    3) displaying pathline info: total distance and area of polygon
i appreciate any help! thank you very much.
May 23, 2015 at 9:03 AM
You should start looking from here I guess, specifically 3, 4, 5, 9, 10. At runtime most likely you will need at least 2 shapefiles, point (to display markers for points) and polygon (to display polygon fill). Perhaps you can store on disk only one of them and generate the other one on app startup.

Hope it helps,
May 23, 2015 at 9:59 AM
for the icon marks works fine but it does not draw the lines, this is the code:
        var utils = new Utils(); 

        Font f = new Font("Arial", 15, FontStyle.Bold);

        System.Drawing.Image im = null;

        var sf = new Shapefile();

        sf.CreateNew(filename, ShpfileType.SHP_POLYLINE);

        m_layerHandle = axMap1.AddLayer(sf, true);

        MapWinGIS.Shape myShape = new Shape();


        sf = axMap1.get_Shapefile(m_layerHandle);

        for (int i = 0; i < numberofpoints; i++)
            im = System.Drawing.Image.FromFile(Path + filename + ".png");

            Graphics graf = Graphics.FromImage(im);

            graf.DrawString(Convert.ToString(i + 1), f, Brushes.Black, 0, 0);

            im.Save(Path + filename + Convert.ToString(i + 1) + ".png");

            MapWinGIS.Image image1 = new MapWinGIS.Image();

            image1.Open(Path + filename + Convert.ToString(i + 1) + ".png", ImageType.USE_FILE_EXTENSION, true, null);

            string categoryName = Convert.ToString(i);

            ShapefileCategory ct = sf.Categories.Add(categoryName);

            ct.DrawingOptions.PointType = tkPointSymbolType.ptSymbolPicture;
            ct.DrawingOptions.Picture = image1;
            ct.DrawingOptions.FrameVisible = true;
            ct.DrawingOptions.LineVisible = true;
            ct.DrawingOptions.LineColor = utils.ColorByName(tkMapColor.Red);
            ct.DrawingOptions.LineWidth = 4;
            ct.DrawingOptions.FillVisible = true;
            sf.set_ShapeCategory(i, i);

            MapWinGIS.Point myPoint = new MapWinGIS.Point();
            myPoint.x = Convert.ToDouble(pathline.GetValue(i, 1).ToString()); 
            myPoint.y = Convert.ToDouble(pathline.GetValue(i, 2).ToString()); 
            myShape.InsertPoint(myPoint, ref i);

        sf.CollisionMode = tkCollisionMode.AllowCollisions;
May 24, 2015 at 12:25 PM
I'd recommend you to write a simpler code and check if you can display a polyline, without trying to display icons or use categories in the same time. Separation of concerns, you know. Then it will be more clear if there is an issue here.