Loads a FeatureClass as a MOLE Force Element Layer into the current IBasicMap (Map, Globe, or Scene).
[C#]
///<summary>Loads a FeatureClass as a MOLE Force Element Layer into the current IBasicMap (Map, Globe, or Scene).</summary> /// ///<param name="featureClass">An IFeatureClass interface to load.</param> ///<param name="basicMap">An IBasicMap interface that is a Map, Scene, or Globe as IBasicMap.</param> ///<param name="layerName">A System.String that is the name to assign to the layer. Example: "Cities"</param> ///<param name="size">A System.Double that is the size of graphics in the layer (in map units). Example: 0.5</param> ///<param name="sizeIsRatio">A System.Boolean setting the SizeIsRatio property. Example: false</param> /// ///<returns>An ILayer interface.</returns> /// ///<remarks> ///1. Obtain a reference to the current IBasicMap. An IBasicMap is used because it is common between ///a Map, Globe, and Scene (and their corresponding Engine Controls) ///For example in a MapControl, IBasicMap bm = this.m_mapControl.Map as IBasicMap; ///2. Load a Feature Class ///3. Call this method to load the feature class as a MOLE Force Element layer ///</remarks> public ESRI.ArcGIS.Carto.ILayer LoadForceElementLayer(ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass, ESRI.ArcGIS.Carto.IBasicMap basicMap, System.String layerName, System.Double size, System.Boolean sizeIsRatio) { if ((featureClass == null) || (basicMap == null)) { System.Diagnostics.Trace.WriteLine("Invalid parameter, aborting"); return null; } ESRI.ArcGIS.Carto.IGeoFeatureLayer geoFeatureLayer = new ESRI.ArcGIS.Carto.FeatureLayer() as ESRI.ArcGIS.Carto.IGeoFeatureLayer; // Dynamic Cast geoFeatureLayer.FeatureClass = featureClass; //Create a MOLE layer and attach the feature layer to it ESRI.ArcGIS.DefenseSolutions.ICachedGraphicFeatureLayer cachedGraphicFeatureLayer = new ESRI.ArcGIS.DefenseSolutions.ForceElementLayerClass() as ESRI.ArcGIS.DefenseSolutions.ICachedGraphicFeatureLayer; cachedGraphicFeatureLayer.FeatureLayer = geoFeatureLayer; //Set the size for symbols in the layer ESRI.ArcGIS.DefenseSolutions.IForceElementLayer forceElementLayer = cachedGraphicFeatureLayer as ESRI.ArcGIS.DefenseSolutions.IForceElementLayer; // Dynamic Cast forceElementLayer.Size = size; forceElementLayer.SizeIsRatio = sizeIsRatio; ESRI.ArcGIS.Carto.ILayer layer = cachedGraphicFeatureLayer as ESRI.ArcGIS.Carto.ILayer; // Dynamic Cast layer.Name = layerName; basicMap.AddLayer(layer); return layer; }
[Visual Basic .NET]
'''<summary>Loads a FeatureClass as a MOLE Force Element Layer into the current IBasicMap (Map, Globe, or Scene).</summary> ''' '''<param name="featureClass">An IFeatureClass interface to load.</param> '''<param name="basicMap">An IBasicMap interface that is a Map, Scene, or Globe as IBasicMap.</param> '''<param name="layerName">A System.String that is the name to assign to the layer. Example: "Cities"</param> '''<param name="size">A System.Double that is the size of graphics in the layer (in map units). Example: 0.5</param> '''<param name="sizeIsRatio">A System.Boolean setting the SizeIsRatio property. Example: false</param> ''' '''<returns>An ILayer interface.</returns> ''' '''<remarks> '''1. Obtain a reference to the current IBasicMap. An IBasicMap is used because it is common between '''a Map, Globe, and Scene (and their corresponding Engine Controls) '''For example in a MapControl, IBasicMap bm = this.m_mapControl.Map as IBasicMap; '''2. Load a Feature Class '''3. Call this method to load the feature class as a MOLE Force Element layer '''</remarks> Public Function LoadForceElementLayer(ByVal featureClass As ESRI.ArcGIS.Geodatabase.IFeatureClass, ByVal basicMap As ESRI.ArcGIS.Carto.IBasicMap, ByVal layerName As System.String, ByVal size As System.Double, ByVal sizeIsRatio As System.Boolean) As ESRI.ArcGIS.Carto.ILayer If (featureClass Is Nothing) OrElse (basicMap Is Nothing) Then System.Diagnostics.Trace.WriteLine("Invalid parameter, aborting") Return Nothing End If Dim geoFeatureLayer As ESRI.ArcGIS.Carto.IGeoFeatureLayer = New ESRI.ArcGIS.Carto.FeatureLayerClass geoFeatureLayer.FeatureClass = featureClass ' Create a MOLE layer and attach the feature layer to it Dim cachedGraphicFeatureLayer As ESRI.ArcGIS.DefenseSolutions.ICachedGraphicFeatureLayer = New ESRI.ArcGIS.DefenseSolutions.ForceElementLayerClass cachedGraphicFeatureLayer.FeatureLayer = geoFeatureLayer ' Set the size for symbols in the layer Dim forceElementLayer As ESRI.ArcGIS.DefenseSolutions.IForceElementLayer = CType(cachedGraphicFeatureLayer, ESRI.ArcGIS.DefenseSolutions.IForceElementLayer) ' Explicit Cast forceElementLayer.Size = size forceElementLayer.SizeIsRatio = sizeIsRatio Dim layer As ESRI.ArcGIS.Carto.ILayer = CType(cachedGraphicFeatureLayer, ESRI.ArcGIS.Carto.ILayer) ' Explicit Cast layer.Name = layerName basicMap.AddLayer(layer) Return layer End Function