//Create a new temporal layer with default symbology private ILayer CreateTemporalLayer() { IFeatureLayer featureLayer = new TemporalFeatureLayerClass(); IFeatureClass featureClass = OpenTrackingServerConnection(); featureLayer.FeatureClass = featureClass; return featureLayer as ILayer; }
//Create a new temporal layer with default symbology private ILayer CreateTemporalLayer() { IFeatureLayer featureLayer = new TemporalFeatureLayerClass(); IFeatureClass featureClass = OpenTrackingServerConnection(); featureLayer.FeatureClass = featureClass; return(featureLayer as ILayer); }
/// <summary> /// Creates a Temporal Layer using the specified feature class and add it to the map. /// </summary> /// <param name="featureClass">The feature class to use for the temporal layer.</param> /// <param name="eventFieldName">Indicates the feature class column that identifies or groups temporal observations with time series.</param> /// <param name="temporalFieldName">Identifies the temporal field, which must be a field type whose data can be converted to a date value.</param> private void AddTemporalLayer(IFeatureClass featureClass, string eventFieldName, string temporalFieldName) { ITemporalLayer temporalFeatureLayer = new TemporalFeatureLayerClass(); IFeatureLayer2 featureLayer = temporalFeatureLayer as IFeatureLayer2; ILayer layer = temporalFeatureLayer as ILayer; ITemporalRenderer temporalRenderer = new CoTrackSymbologyRendererClass(); ITemporalRenderer2 temporalRenderer2 = (ITemporalRenderer2)temporalRenderer; IFeatureRenderer featureRenderer = temporalRenderer as IFeatureRenderer; ITrackSymbologyRenderer trackRenderer = temporalRenderer as ITrackSymbologyRenderer; if (featureLayer != null) { featureLayer.FeatureClass = featureClass; } if (featureRenderer != null) { temporalRenderer.TemporalObjectColumnName = eventFieldName; temporalRenderer.TemporalFieldName = temporalFieldName; temporalFeatureLayer.Renderer = featureRenderer; } if (trackRenderer != null) { //Create green color value IRgbColor rgbColor = new RgbColorClass(); rgbColor.RGB = 0x00FF00; //Create simple thin green line ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = (IColor)rgbColor; simpleLineSymbol.Width = 1.0; //Create simple renderer using line symbol ISimpleRenderer simpleRenderer = new SimpleRendererClass(); simpleRenderer.Symbol = (ISymbol)simpleLineSymbol; //Apply line renderer as track symbol and enable track rendering trackRenderer.TrackSymbologyRenderer = (IFeatureRenderer)simpleRenderer; trackRenderer.ShowTrackSymbologyLegendGroup = true; temporalRenderer2.TrackRendererEnabled = true; } if (layer != null) { ArcMap.Document.FocusMap.AddLayer(layer); } }