自己引用了一个地图控件Gmap,由于其未添加marker的点击事件,所以需要自己写鼠标事件
新建一个GGmarker类继承于地图控件的GmarkerGoogle
public class GGmarker :inherits GmarkerGoogle
???
end class
在Form_Load里面实例化
marker = new GGmarker()
public sub marker_Click() handles marker.Click
msgBox()
end sub
然后marker就可以在地图上显示出一个标记
但是想点击标记的时候能够响应鼠标事件,弹出一个msgbox
请问下怎么写鼠标响应事件呢?
AddHandler
http://blog.csdn.net/lchen1983/article/details/7269878
Class1
Public Class Class1 : Inherits GMarkerGoogle
Public Event Click(ByVal sender As Object, ByVal e As System.EventArgs)
Public Sub New(ByVal p As GMap.NET.PointLatLng, ByVal type As GMap.NET.WindowsForms.Markers.GMarkerGoogleType)
MyBase.New(p, type)
End Sub
Public Sub onMarkerClick(ByVal sender As Object, ByVal e As System.EventArgs)
RaiseEvent Click(sender, e)
End Sub
End Class
在form1里面的代码:
Public Class Form1
Public WithEvents cqqk As Class1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cqqk = New Class1(New PointLatLng(29.5161103860623, 106.929931640625), GMarkerGoogleType.green)
End Sub
Private Sub cqqk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cqqk.Click
MsgBox("调用了marker的鼠标点击事件", MsgBoxStyle.YesNo, "a")
End Sub
End Class