Hi,New to ArcObjects - I have a point in an .mxd layer that I would like to change via user interaction on a form (button click). However, when I run my application and click to update the point, the existing point in the target layer completely disappears. Can anyone point me in the right direction? IMxDocument _mxDoc = (IMxDocument)_doc; IMap map = (IMap)_mxDoc.FocusMap; IGeoFeatureLayer gLayer = (IGeoFeatureLayer)map.get_Layer(2); IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 255; pColor.Blue = 0; ISimpleMarkerSymbol sMarker = new SimpleMarkerSymbol(); sMarker.Color = pColor; sMarker.Style = esriSimpleMarkerStyle.esriSMSDiamond; sMarker.Size = 20; ISimpleRenderer sRender = (ISimpleRenderer)gLayer.Renderer; sRender.Symbol = (ISymbol)sMarker; gLayer.Renderer = (IFeatureRenderer)sRender; IActiveView vActive = (IActiveView)map; vActive.Refresh();
Below is the code I have been using. I stripped out all of the other form controls. I think I cast everything correctly and the problem was with the render. Thanks for taking a look at this.public partial class frmMain : Form { public frmMain() { InitializeComponent(); } //These hold the document and application references private IDocument _doc = null; private IApplication _app = null; //Point button code private void btnPointColor_Click(object sender, EventArgs e) { IMxDocument _mxDoc = (IMxDocument)_doc; //Cast as IMxDocument Interface IMap map = (IMap)_mxDoc.FocusMap; //cast _mxDoc as Carto IMap interface IGeoFeatureLayer gLayer = (IGeoFeatureLayer)map.get_Layer(2); //Cast map layer 3 as IGeoFeature layer //Set the new color for the point IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 255; pColor.Blue = 0; //Point so we need a simple marker symbol ISimpleMarkerSymbol sMarker = new SimpleMarkerSymbol(); sMarker.Color = pColor; sMarker.Style = esriSimpleMarkerStyle.esriSMSDiamond; sMarker.Size = 20; //Need to render ISimpleRenderer sRender = new SimpleRenderer(); sRender.Symbol = (ISymbol)sMarker; gLayer.Renderer = sRender; //_mxDoc.UpdateContents(); IActiveView vActive = (IActiveView)map; vActive.Refresh(); } }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.