ThinkGeo.com    |     Documentation    |     Premium Support

Putting images on top of lines

I have a LineStyle I created to display lines with images for endpoints. The issue I am having is that no matter what order I draw them, the images always appear beneath the line. Is there any way to force the images to appear on top of the line?


 The code I am using is:



    public class ImageEndpointLineStyle : LineStyle
    {
        private LineStyle _lineStyle;
        private GeoImage _firstPointImage;
        private GeoImage _lastPointImage;

        public ImageEndpointLineStyle(LineStyle lineStyle, GeoImage firstPointImage, GeoImage lastPointImage)
        {
            _lineStyle = (LineStyle)lineStyle.CloneDeep();
            _firstPointImage = firstPointImage;
            _lastPointImage = lastPointImage;
        }

        protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInThisLayer, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInAllLayers)
        {
            List<BaseShape> lineShapesToDraw = new List<BaseShape>();
            BaseShape firstPoint = null;
            BaseShape lastPoint = null;
            foreach (Feature feature in features)
            {
                BaseShape shape = feature.GetShape();
                if (shape is LineShape)
                {
                    lineShapesToDraw.Add(shape);
                    LineShape line = (LineShape)shape;
                    firstPoint = new PointShape(line.Vertices[0]);
                    lastPoint = new PointShape(line.Vertices[line.Vertices.Count - 1]);
                }
            }
            new PointStyle(_firstPointImage).Draw(new BaseShape[] { firstPoint }, canvas, labelsInThisLayer, labelsInAllLayers);
            new PointStyle(_lastPointImage).Draw(new BaseShape[] { lastPoint }, canvas, labelsInThisLayer, labelsInAllLayers);
            _lineStyle.Draw(lineShapesToDraw, canvas, labelsInThisLayer, labelsInAllLayers);
        }
    }

 


 


Thanks,


-a.



Hi Adam,


Try this:



_lineStyle.Draw(lineShapesToDraw, canvas, labelsInThisLayer, labelsInAllLayers);
canvas.Flash();
new PointStyle(_firstPointImage).Draw(new BaseShape[] { firstPoint }, canvas, labelsInThisLayer, labelsInAllLayers);
new PointStyle(_lastPointImage).Draw(new BaseShape[] { lastPoint }, canvas, labelsInThisLayer, labelsInAllLayers);


Thanks,


Lee         



That fixed it. Thank you for your help, Lee!



My pleasure :) Please feel free to post any problem you have and share anything you found if you want :) 
  
 Thanks, 
 Lee