Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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. Thanks in advance.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

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
share|improve this answer
    
I had "dynamicMap.DynamicMapEnabled = true;" which was interferring with your example. Thanks for all your help. –  patrick Sep 1 '10 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/… –  Kirk Kuykendall Sep 1 '10 at 17:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.