add a point in mapwingis by mouse and save it to a shapefile using MapWinGIS v4.9.3.6 in vb.net

Sep 28, 2016 at 6:33 AM
Edited Sep 28, 2016 at 6:35 AM
Hi All,
I'm creating an application using MapWinGIS-v4.9.3.6-Win32 in vb.net by visual basic 2005
this is my first time to use axMapWinGIS in vb.net
I dragged the tool into my form and opened a map shapefile

I want a sample code to how to Place a point on map, save it to the shapefile. I saw subject like this through the discussions here but using c# and i didn't know any about c#. So Could you show me the sample code using vb.net, please?

many thanks
Oct 3, 2016 at 10:22 AM
are there any help?
Oct 4, 2016 at 1:06 PM
please I need help
Oct 9, 2016 at 7:46 AM
please I want to know how to add a point in mapwingis by mouse and save it to a shapefile using MapWinGIS v4.9.3.6 in vb.net
Coordinator
Oct 17, 2016 at 11:31 AM
You've send me some more details via e-mail:
Dim shp As New Shape
Dim sf1 As New Shapefile()
Dim x As Double
Dim y As Double


Map1.PixelToProj(e.x, e.y, x, y)
Dim pnt = New MapWinGIS.Point()
pnt.x = x
pnt.y = y
Dim index As Integer = sf1.NumShapes
shp.Create(ShpfileType.SHP_POINT)
shp.InsertPoint(pnt, index)

index = sf1.NumShapes

sf1.CreateNewWithShapeID("", ShpfileType.SHP_POINT)
sf1.EditInsertShape(shp, index)
Map1.AddLayer(sf1, True)
In this vb.net code I try to add points in a shapefile by mouse and I put this code in mouse down event but the problem is that i add every point in a different shapefile I want to put all the points I add by mouse in the Same shapefile. so could you revise my code and correct the the mistakes existed ,please.? I really got exhausted I tried to correct it but useless.
First. Did you read this http://www.mapwindow.org/documentation/mapwingis4.9/getting_started.html

Next I see you create a new shapefile for every point: sf1.CreateNewWithShapeID("", ShpfileType.SHP_POINT)
http://www.mapwindow.org/documentation/mapwingis4.9/group__shapefile__management.html#ga9501a0b966bccd163e66468d8b712bd3

What you need to do is create the shapefile once and add it to the map and save the layer handle.
Next in the OnMouseDown you get this shapefile again using Map1.GetShapefile(hndl): http://www.mapwindow.org/documentation/mapwingis4.9/group__map__layer__management.html#gad42f479b7aca0c8424639a9b619b6cc2

Now add the new shape and do a redraw: http://www.mapwindow.org/documentation/mapwingis4.9/class_ax_map.html#ae1939d284e4959f137357b0ba9336632


Here's a full example: http://www.mapwindow.org/documentation/mapwingis4.9/_mark_points_8cs-example.html