I have some InMemoryFeatureLayers I’m trying to display. For some reason, they only show if I don’t have any other layers on the map. For instance, I have an Overlay containing a shapefile of the countries, and a background layer for the ocean. When I don’t add these to the map, the InMemoryFeatureLayer shows up fine. But when I do add them, the InMemoryFeatureLayer seems to be hidden behind the shapefile layers. How can I fix this?
In this case, the InMemoryFeatureLayer should just display some text at the given long/lat on the map.
Here’s my setup:
LayerOverlay textOverlay = new LayerOverlay(); //holds all the text labels
LayerOverlay worldOverlay = new LayerOverlay(); //holds the background world/ocean layer
private void Map1_Loaded(object sender, RoutedEventArgs e)
{
Map1.MapUnit = GeographyUnit.DecimalDegree;
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer("filepath_to_countries.shp");
AreaStyle areaStyle = new AreaStyle();
areaStyle.FillSolidBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 233, 232, 214));
areaStyle.OutlinePen = new GeoPen(GeoColor.FromArgb(255, 118, 138, 69), 1);
areaStyle.OutlinePen.DashStyle = LineDashStyle.Solid;
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = areaStyle;
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
worldLayer.Name = "World Layer";
worldOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean)));
worldOverlay.Layers.Add("World Layer", worldLayer);
InMemoryFeatureLayer textLayer = new InMemoryFeatureLayer();
textLayer.Name = "Text Layer";
textOverlay.Layers.Add("Text Layer", textLayer);
Map1.Overlays.Add("World Overlay", worldOverlay);
textOverlay.Name = "Text Overlay";
Map1.Overlays.Add("Text Overlay", textOverlay);
}
//function that adds text as an inmemoryfeaturelayer
private void AddText()
{
InMemoryFeatureLayer layer = textOverlay.Layers[0] as InMemoryFeatureLayer;
Feature feature = new Feature(-100, 30);
feature.ColumnValues.Add("TestLabel", "testText");
layer.InternalFeatures.Add(feature);
layer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new TextStyle("textName", new GeoFont("arial", 20, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColors.Red));
layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
textOverlay.Refresh();
}
Thanks,
Dan