ThinkGeo.com    |     Documentation    |     Premium Support

How to keep the raster layer on the bottom

I have a raster layer that I store in the map's Overlay's collection. I also have an InMemoryFeatureLayer that I store in the map's overlays collection. I populate the InMemoryFeatureLayer first and the raster layer second. Also, I update both layers at different times (for example, if the user switches themes I re-fetch the raster layer to show a different theme). Also, the InMemoryFeatureLayer is updated based on changing POIs.


However, the InMemoryFeatureLayer disappears behind the raster layer. How can I arrange this so the raster layer stays on the bottom and the InMemoryFeatureLayer stays on top?



Gregory,


I think you probably make a mistake by setting the sequence of the overlays; we should add the base overlay first and then on top of it add the inmemory overlay.
 
Try following code:

   winformsMap1.MapUnit = GeographyUnit.DecimalDegree;

            winformsMap1.CurrentExtent = new RectangleShape(0, 100, 100, 0);
            winformsMap1.BackgroundOverlay.BackgroundBrush =new GeoSolidBrush(GeoColor.StandardColors.White);

            InMemoryFeatureLayer inMemoryLayer = new InMemoryFeatureLayer();
            inMemoryLayer.InternalFeatures.Add("Polygon", new Feature(BaseShape.CreateShapeFromWellKnownData("POLYGON((10 60,40 70,30 85, 10 60))")));
            inMemoryLayer.InternalFeatures.Add("Multipoint", new Feature(BaseShape.CreateShapeFromWellKnownData("MULTIPOINT(10 20, 30 20,40 20, 10 30, 30 30, 40 30)")));
            inMemoryLayer.InternalFeatures.Add("Line", new Feature(BaseShape.CreateShapeFromWellKnownData("LINESTRING(60 60, 70 70,75 60, 80 70, 85 60,95 80)")));
            inMemoryLayer.InternalFeatures.Add("Rectangle", new Feature(new RectangleShape(65, 30, 95, 15)));

            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(100, GeoColor.StandardColors.RoyalBlue);
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.Blue;
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.FromArgb(200, GeoColor.StandardColors.Red), 5);
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.SymbolPen = new GeoPen(GeoColor.FromArgb(255, GeoColor.StandardColors.Green), 8);
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay staticOverlay = new LayerOverlay(); 
            staticOverlay.Layers.Add("InMemoryFeatureLayer", inMemoryLayer);
           

            GdiPlusRasterLayer worldImageLayer = new GdiPlusRasterLayer(@"..\..\SampleData\Data\world.tif");
            worldImageLayer.UpperThreshold = double.MaxValue;
            worldImageLayer.LowerThreshold = 0;

            LayerOverlay ImageOverlay = new LayerOverlay();
            ImageOverlay.Layers.Add("WorldImageLayer", worldImageLayer);
            winformsMap1.Overlays.Add("ImageOverlay", ImageOverlay);
            winformsMap1.Overlays.Add("InMemoryOverlay", staticOverlay);

            winformsMap1.Refresh();

 

Any more questions please feel free to let me know.
 
Thanks.
 
Yale