Yes, the graphic tracker is handling the refresh for the symbol and it moves perfectly but I need the map to pan as the symbol moves out of view to the user will not have to manually pan while driving.
here is my code.
I have a GPS that is running in the background getting the Lat and Long when it is changing and feeding.
This code below is running on a timer Me.Timer1.Interval = 500 and works great for the graphic tracker.
Sub Lat_Long(ByRef Latcoord As String, ByVal Longcoord As String)
Dim activeView As IActiveView = TryCast(map, IActiveView)
If Latcoord <> "" And Longcoord <> "" Then
m_graphicTracker.Initialize(TryCast(map, IBasicMap))
Dim gc As IGraphicsContainer
gc = activeView
' Get the spatial reference of the map (UTM)
Dim sr As ISpatialReference
sr = activeView.FocusMap.SpatialReference
'' Create a point and assign the geographic coordinate system (lat/long)
Dim point As IPoint = New ESRI.ArcGIS.Geometry.Point
' Get the geographic coordinate system used by the map's spatial reference (lat/long)
Dim geoSR As ISpatialReference
Dim psr As IProjectedCoordinateSystem
psr = sr
geoSR = psr.GeographicCoordinateSystem
point.SpatialReference = geoSR
' Give the point coordinates known to exist in the current extent
point.PutCoords(Longcoord, Latcoord)
point.Project(sr)
If PointFirstTime = True Then
'Get the Graphic Symbol
Dim gtSymbol As IGraphicTrackerSymbol = m_GTSymbols(2)
Dim id As Integer = m_graphicTracker.Add(TryCast(point, IGeometry), gtSymbol)
m_GTGeometries.Add(0, TryCast(point, IGeometry))
m_graphicTracker.Replace(0, m_GTGeometries(0), m_GTSymbols(2))
End If
If m_graphicTracker IsNot Nothing Then
For i As Integer = 0 To m_graphicTracker.Count - 1
Dim id1 As Integer = i
If m_GTGeometries.ContainsKey(id1) Then
'Dim pnt As IPoint = DirectCast(m_GTGeometries(id), IPoint)
Dim pnt As IPoint = point
Dim x As Double = pnt.X
Dim y As Double = pnt.Y
m_graphicTracker.MoveTo(id1, x, y, 0)
m_GTGeometries.Remove(id1)
Dim point1 As IPoint = New ESRI.ArcGIS.Geometry.Point
point1.PutCoords(x, y)
m_GTGeometries.Add(id1, point1)
Try
If activeView Is Nothing Then
Return
End If
Dim screenDisplay As ESRI.ArcGIS.Display.IScreenDisplay = activeView.ScreenDisplay
'Here I am trying a couple of ways to get it to pan
Dim envelope As ESRI.ArcGIS.Geometry.IEnvelope = activeView.Extent
envelope.CenterAt(point1)
envelope.Expand(0, 0, True)
activeView.Extent = envelope
'This causes a blip
' activeView.Refresh()
point.PutCoords(SaveLongCoord, SaveLatCoord)
point.Project(sr)
activeView.CenterAt(point)
'This causes a blip
'activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, TryCast(basemapLayer, Object), Nothing)
Catch ex As Exception
End Try
End If
Next
End If
PointFirstTime = False
End If
End Sub