protected override void OnClick() { if (!m_bIsConnected) { try { //open the shapefile with the recorded data IFeatureClass featureClass = openPlaybackData(); if (null == featureClass) { return; } //get the map container object mapObj = ArcMap.Application; //load the Tracking Analyst extension ITrackingEnvironment3 trackingEnv = setupTrackingEnv(ref mapObj); //set the mode to historic, since you need to do playback trackingEnv.DefaultTemporalReference.TemporalMode = enumTemporalMode.enumHistoric; //set the units of the temporal period to days trackingEnv.DefaultTemporalReference.TemporalPeriodUnits = enumTemporalUnits.enumDays; //set the update mode to manual so that it will be controlled by the application trackingEnv.DisplayManager.ManualUpdate = true; //set the temporal perspective to Aug 03 2000 7PM. trackingEnv.DefaultTemporalReference.TemporalPerspective = "8/3/2000 7:0:00 PM"; // Stop using the map's time to allow the layer to draw based on it's TemporalPerspective ITimeData timeData = m_temporalLayer as ITimeData; timeData.UseTime = false; //create a temporal operator that will serve as a base time for the tracking environment ITemporalOperator3 temporalOpBaseTime = new TemporalOperatorClass() as ITemporalOperator3; //set the base time to 6PM, Aug 3 2000 temporalOpBaseTime.SetDateTime(2000, 8, 3, 18, 0, 0, 0); //create the renderer for the temporal layer ITemporalRenderer temporalRenderer = setRenderer(featureClass, "DATE_TIME", "EVENTID"); //create the temporal layer for the playback data m_temporalLayer = new TemporalFeatureLayerClass(); //assign the featureclass for the layer ((IFeatureLayer)m_temporalLayer).FeatureClass = featureClass; //set the base time to initialize the time window of the layer m_temporalLayer.RelativeTimeOperator = (ITemporalOperator)temporalOpBaseTime; //set the renderer for the temporal layer m_temporalLayer.Renderer = temporalRenderer as IFeatureRenderer; //set the flag in order to display the track of previous locations m_temporalLayer.DisplayOnlyLastKnownEvent = false; //initialize labels for the event name setupLayerLabels(m_temporalLayer, "EVENTID"); m_activeView = ArcMap.Document.ActiveView; m_temporalEnv = trackingEnv; m_baseTime = temporalOpBaseTime; //add the temporal layer to the map ArcMap.Document.FocusMap.AddLayer((ILayer)m_temporalLayer); //enable the timer m_timer.Enabled = true; } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } } else { //disable the timer m_timer.Enabled = false; if (null == m_temporalLayer) { return; } //remove the layer ArcMap.Document.FocusMap.DeleteLayer((ILayer)m_temporalLayer); m_temporalLayer = null; } m_bIsConnected = !m_bIsConnected; m_docEvent = ArcMap.Document as IDocumentEvents_Event; m_docEvent.CloseDocument += new IDocumentEvents_CloseDocumentEventHandler(docEvent_CloseDocument); ArcMap.Application.CurrentTool = null; }
protected override void OnClick() { if (!m_bIsConnected) { try { //open the shapefile with the recorded data IFeatureClass featureClass = openPlaybackData(); if (null == featureClass) return; //get the map container object mapObj = ArcMap.Application; //load the Tracking Analyst extension ITrackingEnvironment3 trackingEnv = setupTrackingEnv(ref mapObj); //set the mode to historic, since you need to do playback trackingEnv.DefaultTemporalReference.TemporalMode = enumTemporalMode.enumHistoric; //set the units of the temporal period to days trackingEnv.DefaultTemporalReference.TemporalPeriodUnits = enumTemporalUnits.enumDays; //set the update mode to manual so that it will be controlled by the application trackingEnv.DisplayManager.ManualUpdate = true; //set the temporal perspective to Aug 03 2000 7PM. trackingEnv.DefaultTemporalReference.TemporalPerspective = "8/3/2000 7:0:00 PM"; // Stop using the map's time to allow the layer to draw based on it's TemporalPerspective ITimeData timeData = m_temporalLayer as ITimeData; timeData.UseTime = false; //create a temporal operator that will serve as a base time for the tracking environment ITemporalOperator3 temporalOpBaseTime = new TemporalOperatorClass() as ITemporalOperator3; //set the base time to 6PM, Aug 3 2000 temporalOpBaseTime.SetDateTime(2000, 8, 3, 18, 0, 0, 0); //create the renderer for the temporal layer ITemporalRenderer temporalRenderer = setRenderer(featureClass, "DATE_TIME", "EVENTID"); //create the temporal layer for the playback data m_temporalLayer = new TemporalFeatureLayerClass(); //assign the featureclass for the layer ((IFeatureLayer)m_temporalLayer).FeatureClass = featureClass; //set the base time to initialize the time window of the layer m_temporalLayer.RelativeTimeOperator = (ITemporalOperator)temporalOpBaseTime; //set the renderer for the temporal layer m_temporalLayer.Renderer = temporalRenderer as IFeatureRenderer; //set the flag in order to display the track of previous locations m_temporalLayer.DisplayOnlyLastKnownEvent = false; //initialize labels for the event name setupLayerLabels(m_temporalLayer, "EVENTID"); m_activeView = ArcMap.Document.ActiveView; m_temporalEnv = trackingEnv; m_baseTime = temporalOpBaseTime; //add the temporal layer to the map ArcMap.Document.FocusMap.AddLayer((ILayer)m_temporalLayer); //enable the timer m_timer.Enabled = true; } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } } else { //disable the timer m_timer.Enabled = false; if (null == m_temporalLayer) return; //remove the layer ArcMap.Document.FocusMap.DeleteLayer((ILayer)m_temporalLayer); m_temporalLayer = null; } m_bIsConnected = !m_bIsConnected; m_docEvent = ArcMap.Document as IDocumentEvents_Event; m_docEvent.CloseDocument += new IDocumentEvents_CloseDocumentEventHandler(docEvent_CloseDocument); ArcMap.Application.CurrentTool = null; }