Show Point

Feb 3, 2015 at 4:07 AM
Hello, im new user of mapWinGis
i want to draw a point on my C# project based on MySQL data, for first time i try to create just one point and not use the SQL.
but i didn't get the point show at my map
this is my code

private void btnShow_Click(object sender, EventArgs e)

    public void MarkPoints()
        //axMap1.Projection = tkMapProjection.PROJECTION_WGS84;

        var sf = new Shapefile();
        sf = axMap1.get_Shapefile(m_layerHandle);// in case a copy of shapefile was created by GlobalSettings.ReprojectLayersOnAdding

        sf = new Shapefile();
        if (!sf.CreateNewWithShapeID("", ShpfileType.SHP_POINT))
            MessageBox.Show("Failed to create shapefile: " + sf.ErrorMsg[sf.LastErrorCode]);

        m_layerHandle = axMap1.AddLayer(sf, true);

        ShapeDrawingOptions options = sf.DefaultDrawingOptions;
        options.PointType = tkPointSymbolType.ptSymbolPicture;

        // Opens a marker from the file
        // </summary>
        string imgfilename = @"D:\Users\Alexander\Documents\Visual Studio 2010\Projects\SQL with MapWinGis\SQL with MapWinGis\icon\marker.png";
        if (!File.Exists(imgfilename))
            MessageBox.Show("Can't find the file: " + imgfilename);
            Image img = new Image();
            if (!img.Open(imgfilename, ImageType.USE_FILE_EXTENSION, true, null))
                options.Picture = img;

        sf.CollisionMode = tkCollisionMode.AllowCollisions;


    public void drawPoints()
        Shapefile sf = axMap1.get_Shapefile(m_layerHandle);

        Shape shp = new Shape();

        Point pnt = new Point();
        double x = 0.0;
        double y = 0.0;
        x = -6.412;
        y = 106;
        pnt.x = x;
        pnt.y = y;
        int index = shp.numPoints;
        shp.InsertPoint(pnt, ref index);

        index = sf.NumShapes;
        if (!sf.EditInsertShape(shp, ref index))
            MessageBox.Show("Failed to insert shape: " + sf.ErrorMsg[sf.LastErrorCode]);
        MessageBox.Show("Draw Ok");
i receive Draw Ok, but i can't see the marker on my map.
Feb 3, 2015 at 8:17 AM
Edited Feb 3, 2015 at 8:19 AM
Hi, try to add axMap1.ZoomToLayer(m_layerHandle) call.
Also y is latitude, i.e. should be in range [-90; 90], so perhaps x and y are mixed up.
  sf = axMap1.get_Shapefile(m_layerHandle);// in case a copy of shapefile was created by GlobalSettings.ReprojectLayersOnAdding
int the beginning isn't necessary, you haven't added the layer to the map at this point.
Shape.AddPoint rather than Shape.InsertPoint in the second function can spare you some code lines.
axMap1.Projection = tkMapProjection.PROJECTION_WGS84 is fine if you want to see background tiles and provide coordinates in decimal degrees.
Also perhaps samples listed here may be helpful (9th in particular).

Hope it'll help,
Marked as answer by pmeems on 2/6/2015 at 2:39 AM
Feb 5, 2015 at 10:24 AM
Thanks for your suggestion. Now i can draw a point based MySQL data