Hello,
I want to be sure my legends do not cover a specific layer on the map, so if they do I make some changes to extent (zoom out/shift) to be sure they are not covered. I have a method that works if you make some assumptions on were the legend is (lower left in this case). But I'm wondering if there is a way to get the screen or world coordinate of an adorner layer so I can make my detection code work in any case. Not had any luck looking at the API or forums so far, below is my current code.
I'm sure I could add a switch for all possible adorner placements and then calculate its screen coordinates but wonder if there is an easier way.
Thanks
protected virtual bool LayerOverlapsLegend(FeatureLayer layer, LegendAdornmentLayer legend)
{
var upperLeftLegendPoint = ExtentHelper.ToWorldCoordinate(Map.CurrentExtent, new ScreenPointF(0, Map.Height - legend.Height), Map.Width, Map.Height);
var lowerRightLegendPoint = ExtentHelper.ToWorldCoordinate(Map.CurrentExtent, new ScreenPointF(legend.Width, Map.Height), Map.Width, Map.Height);
var legendBBox = new RectangleShape(upperLeftLegendPoint, lowerRightLegendPoint);
return layer.QueryTools.GetFeaturesOverlapping(legendBBox, ReturningColumnsType.NoColumns).Count > 0;
}