1

I have a Customer layer which inherits BaseCustomLayer.

I add it to my MapControl via addLayer but the function public override void Draw(esriDrawPhase drawPhase, IDisplay Display, ITrackCancel trackCancel) is never hit.

The Custom Layer appears checked in the TOC.

I think I must be missing some initialization one-liner.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Sep 1, 2010 at 15:27

1 Answer 1

7

Here's a minimalist custom layer:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.esriSystem;
namespace MapControlApplication1
{
 class CustLayer2: BaseCustomLayer
 {
 public override void Draw(esriDrawPhase drawPhase, IDisplay Display, ITrackCancel trackCancel)
 {
 System.Diagnostics.Debug.Print("drawing {0} {1}", drawPhase, Environment.TickCount);
 }
 }
}

I created a new Project and choosing C#>ArcGIS>Extending ArcObjects>Mapcontrol Application, then added a new menuitem on the menu of MainForm with this:

private void testToolStripMenuItem_Click(object sender, EventArgs e)
{
 try
 {
 CustLayer2 layer = new CustLayer2();
 layer.Name = "cust layer2";
 axMapControl1.AddLayer(layer);
 }
 catch (Exception ex)
 {
 MessageBox.Show(this, ex.Message);
 }
}

When I run I see this output as I pan around the map:

drawing esriDPGeography 441416029
drawing esriDPGeography 441422207
drawing esriDPGeography 441433579
answered Sep 1, 2010 at 16:16
2
  • I had "dynamicMap.DynamicMapEnabled = true;" which was interferring with your example. Thanks for all your help. Commented Sep 1, 2010 at 16:28
  • Ahh, that makes sense. For a custom layer to draw when the dynamicmap is enabled, I think you'll need to implement IDynamicLayer too. help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/… Commented Sep 1, 2010 at 17:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.