Thomas,
I think I understand what you need so let me put this forward. What we want to do is to allow you to control then the VirtualEarthLayer is shown or not. Currently in its default form it will always show but for reasons you mentioned this is not always desirable.
What I am doing in the code below is to inherit from the VirtualEarthLayer and the adding some properties that will bound the drawing. We then override the DrawCore method which is called when the layer draws. Inside of here we check to see if the current scale is what we have bounded in the properties. If it is ok then we call the base method, if not then we do not call the base method and nothing happens. The code should be fairly straight forward.
Let me know if this does what you need. BTW I was not able to test this before posting but you can put breakpoints in and debug it. Any changes should be minor, I am fairly certain about the logic and structure of what needs to happen.
David
public class BoundedVirtualEarthLayer : VirtualEarthLayer
{
double upperScale;
double lowerScale;
// This constructor is the default and it just calls the main one with default values
public BoundedVirtualEarthLayer()
: this(double.MaxValue, 0)
{ }
// This is the mian constructor and allows you to pass in the upper and lower
// scales the layer will be bounded to
public BoundedVirtualEarthLayer(double upperScale, double lowerScale)
{
this.upperScale = upperScale;
this.lowerScale = lowerScale;
}
// This is the upper scale. Above this scale the layer will not draw
public double UpperScale
{
get { return upperScale; }
set { upperScale = value; }
}
// This is the lower scale. Below this scale the layer will not draw
public double LowerScale
{
get{return lowerScale;}
set{lowerScale = value;}
}
// Here we override the DrawCore methos and we check the current scale. If it is within our
// bounderies then we draw it by calling into the base, if not then we just ignore the call.
protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
{
double currentScale = ExtentHelper.GetScale(canvas.CurrentWorldExtent, canvas.Width, canvas.MapUnit);
if (currentScale >= lowerScale && currentScale <= upperScale)
{
base.DrawCore(canvas, labelsInAllLayers);
}
}
}