Quantcast
Viewing all articles
Browse latest Browse all 2341

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

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

Viewing all articles
Browse latest Browse all 2341

Trending Articles