pan as my graphic tracker symbol moves

3481
36
08-14-2013 08:45 AM
DarcyHathaway
New Contributor
I need help to make the map pan as my graphic tracker symbol moves based on the GPS feed.
I am using Arc Object 10 with VS.net VB.
0 Kudos
36 Replies
JeffMatson
Occasional Contributor III
I need help to make the map pan as my graphic tracker symbol moves based on the GPS feed.
I am using Arc Object 10 with VS.net VB.


The basic method would be to use IActiveView and IEnvelope.  Each time your graphic tracker symbol moves, use IEnvelope.CenterAt() and reset your IActiveView.Extent to the updated Envelope, and then refresh.
0 Kudos
DarcyHathaway
New Contributor
The basic method would be to use IActiveView and IEnvelope.  Each time your graphic tracker symbol moves, use IEnvelope.CenterAt() and reset your IActiveView.Extent to the updated Envelope, and then refresh.


That will not work because the map refreshes every time the GPS changes this is every half a second. It causes the map to blip and is very ugly, not acceptable.
0 Kudos
JeffMatson
Occasional Contributor III
That will not work because the map refreshes every time the GPS changes this is every half a second. It causes the map to blip and is very ugly, not acceptable.


There are many ways to refresh the map without the dreaded "blipping" but it depends on how you are going about things.  Maybe if you post some more information or a code sample someone can help.
0 Kudos
LeoDonahue
Occasional Contributor III
You could look at:  com.esri.arcgis.carto.CenterAndScale

Graphics Tracker should be handling your refresh, right?  You are not explicitly calling map.refresh are you?
0 Kudos
DarcyHathaway
New Contributor
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
0 Kudos
JeffMatson
Occasional Contributor III
You might need to cache your layers (not sure what type of layer 'basemapLayer' is) to avoid the blips.

Also since you have an envelope, pass that into partialRefresh.  Lastly you might need to change the draw phase being passed into partialRefresh (you can also combine several draw phases)

Hope that helps
0 Kudos
DarcyHathaway
New Contributor
I am creating this in a window application.

I tried activeView.PartialRefresh(esriViewDrawPhase.esriViewBackground, Nothing, envelope) and it is not working.
0 Kudos
LeoDonahue
Occasional Contributor III
partial refresh is not working or it is not giving you the effect you wanted?
0 Kudos
DarcyHathaway
New Contributor
It is not giving me the effect I want.

I really need the map to pan to the point as the point moves.
0 Kudos