ThinkGeo.com    |     Documentation    |     Premium Support

Restriction Layer Bug?

HI, I'm using the latest public version of the Desktop Edition RC and I think there may be a bug with the restriction layer.


What I'm doing is creating a RestrictionLayer and adding it as the last layer in the Overlay that holds all my layers (World map Kit).  The RestrictionLayer covers up most of the stuff, but once I zoom in around the border of the RestrictionLayer I can see the labels for the cities and roads.  It looks like the labels aren't being covered up by the restriction layer and they drawing on top.  I think I can work around it by adding the RestrictionLayer to a new overlay, but I really don't want to do this unless I have too.


Thanks


 



Clint, 


Thanks for your report! We can create the problem as you said very easily!
 
Currently, in our drawing logic, we will always draw the label at the top of each overlay, so there is 2 ways to go around this problem without changing anything in MapSuite component.
 
1) As you said, put it to another Overlay.
 
2) Put it into one overlay, but need to create a special RestrictionAreaStyle, Following is the sample code you can follow.

//Create a RestricitonAreaStyle and Override the DrawCore.
    public class RestrictionAreaStyle : AreaStyle
    {
        public RestrictionAreaStyle()
            :base()
        { 
        }

        public RestrictionAreaStyle(GeoPen outlinePen)
            : base(outlinePen)
        { 
        }

        public RestrictionAreaStyle(GeoSolidBrush fillSolidBrush)
            :base(fillSolidBrush)
        {
        }

        public RestrictionAreaStyle(GeoPen outlinePen, GeoSolidBrush fillSolidBrush)
            : base(outlinePen, fillSolidBrush)
        { 
        }

        public RestrictionAreaStyle(GeoPen outlinePen, GeoSolidBrush fillSolidBrush, PenBrushDrawingOrder penBrushDrawingOrder)
            : base(outlinePen, fillSolidBrush, penBrushDrawingOrder)
        { 
        }

        protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInThisLayer, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInAllLayers)
        {
            if (canvas.CurrentWorldExtent.Width == 0) { return; }

            foreach (Feature feature in features)
            {
                WellKnownType shapeWellKnownType = feature.GetWellKnownType();
                if (shapeWellKnownType != WellKnownType.Polygon && shapeWellKnownType != WellKnownType.Multipolygon)
                {
                    continue;
                }

                canvas.DrawArea(feature, OutlinePen, Advanced.FillCustomBrush, DrawingLevel.LabelLevel, XOffsetInPixel, YOffsetInPixel, PenBrushDrawingOrder);
            }
        }

//Use the Created Restriction Style for the RestrictionLayer.
GeoPen geoPen = new GeoPen(GeoColor.StandardColors.Transparent, 0);
            geoPen.DashStyle = LineDashStyle.Solid;
            GeoHatchBrush brush = new GeoHatchBrush(GeoHatchStyle.Percent80, GeoColor.StandardColors.LightGray, GeoColor.StandardColors.Black);

            RestrictionAreaStyle areaStyle = new RestrictionAreaStyle();
            areaStyle.Advanced.FillCustomBrush = brush;
            areaStyle.OutlinePen = geoPen;

            restrictionLayer.CustomStyles.Add(areaStyle);

Any more questions just let me know.


Thanks.
 
Yale