我正在Gmaps.Net中创建控件,并设法在其中动态添加标记。首先,我想让标记运行不同的代码。
假设我在地图上预设了3个标记。
1 - `Camera1.Show()`
2 - `Camera2.Show()`
3 - `Camera3.Show()`
如果有人想添加另一个,它应该运行4-Camera2.Show()
或任何他想将该标记绑定到的相机。
我现在想的过程是,由于我将有一个用于保存标记位置的数据库,是否也可以在MS Access中保存代码?
像。。
获取此代码--Camera5.Show()
并将其添加到动态添加的按钮中。。谢谢
更新:这是我的一些代码。。
Dim f2c1 As New Form2
Dim f2c2 As New Form2
Dim f2c3 As New Form2
Dim camera1 As New GMapMarkerGoogleGreen(New PointLatLng(14.579929, 121.058901))
If item Is camera1 Then ' camera1 is one of the markers that I predefined in the code
With f2c1 ' so in terms of adding more, I need to save the new ones' latlong in DB
If .Visible = True Then
.Hide()
Else
.Show()
.AxXHDec1.Camera = 1 ' camera ID--needs database
.AxXHDec1.Host = "some ip add" ' host address--needs database
.AxXHDec1.Play = 1 ' true / false
.AxXHDec1.Command = "SetPass -4 guest guest" ' some password
.AxXHDec1.ShowText = 7
.AxXHDec1.ShowInfo = 1
map_OnMapDrag()
End If
End With
End If
这在某种程度上是我想再次使用的。我正在考虑将其添加到某个function
中,因为我只将Form2
的实例创建为f2c1
、f2c2
、f2c3
,aXxhdec是一个activeX。好在可以只用一个。
Public Class Camera
private _myCam As I_AM_NOT_SURE
_Lat As Single = 0
Friend Property Latitude As Single
Get
Return _Lat
End Get
Set(ByVal value As Single)
_Lat = value
End Set
End Property
_Long As Single = 0
Friend Property Longitude As Single
Get
Return _Long
End Get
Set(ByVal value As Single)
_Long = value
End Set
End Property
' a way to make the camera take care of itself:
Public Sub CreateView
myCam = New GMapMarkerGoogleGreen( _
New PointLatLng(_Lat, _Long ))
... the rest of that code
End Sub
你的代码在我看来是由内而外的。相机不仅要管理设置,还要创建"视图"。代码中的大多数文字都是变量,可以保存/读取等。Lat/Long似乎是最重要的。保存时,从类中获取值并保存到任何位置:
dbLat var.... = Camera1.Latitude
dbLong var.... = Camera1.Longitude
然后把它们放回去。从数据库中读取数据并:
Dim Camera1 as New Camera
Camera1.Longitude = dt.row(0)("Longitude")
Camera1.Latitude = dt.row(0)("Latitude")
... etc
End With
Camera1.CreateView ' create the view (?)
非常粗糙,但我没有太多要说的,但变量的原理和通过属性暴露它们就是重点。