以下是引用gyhcly在2005-6-15 23:31:59的发言:
版主,菜菜的问一下,为什么回放的时候所有的点都显示在TEMPLATE层上?
怎么实现只显示一个点的移动呢?而且回放结束以后,所有的点信息仍然保存在TEMPLATE层上,怎么清空呢?
可以修改playNMEA函数,删除前面的图元
Public Sub playNMEA(sArray As Variant)
'读取存有GPS信息的回放文件
Dim rmc As GPRMC
Dim Utils As New CParseUtils
Dim Sentence As Integer
Dim mapDest As MapXLib.Map
Dim mobileObj As New MapXLib.Feature
Dim mobileFtr As New MapXLib.Feature
Dim lnFeat As New MapXLib.Feature
Dim FeatFact As MapXLib.FeatureFactory
Dim GPSPoints As New MapXLib.Points, aPoint As New MapXLib.Point
Dim NewStyle As New Style
Dim GPSLayerID As Integer
Dim intReg As Integer
Dim DD_X As Double, DD_Y As Double
Dim BJ_X As Double, BJ_Y As Double
Dim yy As String, mm1 As String, dd As String '年、月、日
Dim hh As String, mm2 As String, ss As String '时、分、秒
Dim ftrID As Long
intReg = 0.00012
Set mapDest = frmGPS_Disp.mapMain '这里是用于显示地图的表单及控件名
GPSLayerID = 1 'mapDest.Layers.Count
ftrID = 1
If mapDest.Layers.Count > 1 Then
Set mapDest.Layers.AnimationLayer = mapDest.Layers(GPSLayerID)
Else
MsgBox "没有地图,请先打开地图!"
Exit Sub
End If
mobileFtr.Attach mapDest
mobileFtr.Type = miFeatureTypeSymbol
With NewStyle
.SymbolFont.Name = "Mapinfo symbols"
.SymbolCharacter = 50 ';H40 '塔符号0X40,圆形符号0X2F
.SymbolFont.Size = 10 ' 设置符号大小
.SymbolFontRotation = 0
.SymbolFontShadow = False
.SymbolFontHalo = False
.SymbolFontColor = 255 ' 定义为红色...
.SymbolFontBackColor = miColorWhite
End With
mobileFtr.Style = NewStyle
mobileFtr.Point.Set 0, 0
Set mobileObj = mapDest.Layers(GPSLayerID).AddFeature(mobileFtr)
For Sentence = 0 To sCnt - 1
If Utils.Parse(sArray(Sentence), 1) = "$GPRMC" Then
Set rmc = New GPRMC
DoEvents
With rmc
.Sentence = sArray(Sentence)
If Not Val(.Longitude) = 0 Then
DD_X = DM2DD(.Longitude)
DD_Y = DM2DD(.Latitude)
frmGPS_Disp.lblX.Caption = "X: " ; Format(DM2DD(.Longitude), "000.0000") ; " " ; .LonHemis
frmGPS_Disp.lblY.Caption = "Y: " ; Format(DM2DD(.Latitude), " 00.0000") ; " " ; .LatHemis
If bDispType = 1 Then 'bDispType为显示类型,1--单点显示
mapDest.Layers.Item("GPSLayer").DeleteFeature ftrID '清除以前的图元
End If
If mapDest.NumericCoordSys.Units = miUnitDegree Then '度
mobileFtr.Point.Set DD_X, DD_Y
Else '米 BJ54坐标系
'经纬度BL换算到高斯平面直角坐标XY(高斯投影正算)
Deg2XY DD_X, DD_Y, BJ_X, BJ_Y
mobileFtr.Point.Set BJ_X, BJ_Y
End If
Set mobileObj = mapDest.Layers(GPSLayerID).AddFeature(mobileFtr)
ftrID = mobileObj.FeatureID
'mapDest.Layers(GPSLayerID).Refresh
If mobileFtr.Point.X > mapDest.Bounds.XMax - intReg Or _
mobileFtr.Point.X < mapDest.Bounds.XMin + intReg Or _
mobileFtr.Point.Y > mapDest.Bounds.YMax - intReg Or _
mobileFtr.Point.Y < mapDest.Bounds.YMin + intReg Then
mapDest.CenterX = mobileFtr.Point.X
mapDest.CenterY = mobileFtr.Point.Y
End If
frmGPS_Disp.lblSpeed.Caption = "速度: " ; Val(.Speed) ; " Km/h"
'日期的格式转换: 250503 -> 03/05/25
dd = Mid$(.UTDate, 1, 2)
mm1 = Mid$(.UTDate, 3, 2)
yy = Mid$(.UTDate, 5, 2)
frmGPS_Disp.lblDate.Caption = "日期: " ; Format(yy + mm1 + dd, "00/00/00")
'UTC时间转换为北京时间
hh = Mid$(.UTC, 1, 2) + 8
mm2 = Mid$(.UTC, 3, 2)
ss = Mid$(.UTC, 5, 2)
frmGPS_Disp.lblUTC.Caption = "时间: " ; Format(hh + mm2 + ss, "00:00:00")
Else
MsgBox "接收卫星太少,不能定位!"
frmGPS_Disp.lblX.Caption = "X: "
frmGPS_Disp.lblY.Caption = "Y: "
frmGPS_Disp.lblSpeed.Caption = "速度: "
frmGPS_Disp.lblDate.Caption = "日期: "
frmGPS_Disp.lblUTC.Caption = "时间: "
Exit Sub
End If
End With
End If
Next Sentence
Set mapDest = Nothing
Set mobileObj = Nothing
Set mobileFtr = Nothing
Set lnFeat = Nothing
Set FeatFact = Nothing
Set GPSPoints = Nothing
Set NewStyle = Nothing
End Sub
本程序中,指定了一个名为“GPSLayer”临时图层,用于显示GPS点