Hi
Could someone give a newbie with the MapWinGIS ActiveX an example or put me in the right direction.
I have succeeded open a .png map and put in the .bmp markers I want on the map.
If I want to drag this markers to a new point, how can I do this?
Public Sub AxMap1MouseDownEvent(sender As Object, e As _DMapEvents_MouseDownEvent)
Could someone give a newbie with the MapWinGIS ActiveX an example or put me in the right direction.
I have succeeded open a .png map and put in the .bmp markers I want on the map.
If I want to drag this markers to a new point, how can I do this?
Public Sub AxMap1MouseDownEvent(sender As Object, e As _DMapEvents_MouseDownEvent)
If e.button = 1 Then
' left button
Dim sf = New Shapefile()
sf = New Shapefile()
If Not sf.CreateNewWithShapeID("", ShpfileType.SHP_POINT) Then
MessageBox.Show("Failed to create shapefile: " + sf.ErrorMsg(sf.LastErrorCode))
Return
End If
m_layerHandle = AxMap1.AddLayer(sf, True)
sf.CollisionMode = tkCollisionMode.AllowCollisions
Dim img As New Image
img = Me.OpenMarker
Dim options As ShapeDrawingOptions = sf.DefaultDrawingOptions
options.PointType = tkPointSymbolType.ptSymbolPicture
options.Picture = img
Dim shp As New Shape()
shp.Create(ShpfileType.SHP_POINT)
Dim pnt As New Point()
Dim x As Double = 0.0
Dim y As Double = 0.0
axMap1.PixelToProj(e.x, e.y, x, y)
pnt.x = x
pnt.y = y
Dim index As Integer = shp.numPoints
shp.InsertPoint(pnt, index)
index = sf.NumShapes
If Not sf.EditInsertShape(shp, index) Then
MessageBox.Show("Failed to insert shape: " + sf.ErrorMsg(sf.LastErrorCode))
Return
End If
axMap1.Redraw()
End If
End Sub
Private Function OpenMarker() As Image
Dim path As String = Me.TextBox1.Text ‘Path to icon
If Not File.Exists(path) Then
MessageBox.Show(Convert.ToString("Can't find the file: ") & path)
Else
Dim img As New Image()
If Not img.Open(path, ImageType.USE_FILE_EXTENSION, True, Nothing) Then
MessageBox.Show(img.ErrorMsg(img.LastErrorCode))
img.Close()
Else
Return img
End If
End If
Return Nothing
End Function
Thanks Anders