# LegendAdornmentLayer not display

**URL:** <https://community.thinkgeo.com/t/legendadornmentlayer-not-display/10055>\
**Category:** WPF\
**Created:** [April 16, 2021, 12:34pm UTC](https://community.thinkgeo.com/t/legendadornmentlayer-not-display/10055 "2021-04-16T12:34:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torsten](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/8e8cbc/32.png) [@Torsten](https://community.thinkgeo.com/u/Torsten)\
**Post date:** [April 16, 2021, 12:34pm UTC](https://community.thinkgeo.com/t/legendadornmentlayer-not-display/10055/1 "2021-04-16T12:34:00Z")

</div>

Hallo,  
I try to add a LegendAdornmentLayer in Code to the AdornmentOverlay. Basicly I use the same code as given in the “HowDoI-Example” (CreateClassBreakStyleSample.xaml.cs)  
The layer is added to the Overlay (check in debug-window). The Overlay and the Layer property “IsVisible” are true. but the LegendLayer is not displayed. The ScalebarLayer (in the same Overlay) is displayed.

When I place the example-code in the Loaded-Event from the Usercontrol, the Legend is drawn.  
Any suggestions?

Regards Torsten

---

<div class="post-metadata">

**Author:** ![Frank4](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/frank4/32/25224_2.png) [@Frank4](https://community.thinkgeo.com/u/Frank4)\
**Post date:** [April 16, 2021, 4:42pm UTC](https://community.thinkgeo.com/t/legendadornmentlayer-not-display/10055/2 "2021-04-16T16:42:21Z")

</div>

Thanks Torsten,  
I tried with the how do I sample. CreateClassBreakStyleSample.xaml.cs missed one line

` mapView.Refresh();`

So the full code will like this  
private void MapView\_Loaded(object sender, RoutedEventArgs e)  
{  
// Set the map’s unit of measurement to meters(Spherical Mercator)  
mapView.MapUnit = GeographyUnit.Meter;

```
            // Add Cloud Maps as a background overlay
            var thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("itZGOI8oafZwmtxP-XGiMvfWJPPc-dX35DmESmLlQIU~", "bcaCzPpmOG6le2pUz5EAaEKYI-KSMny_WxEAe7gMNQgGeN9sqL12OA~~", ThinkGeoCloudVectorMapsMapType.Light);
            mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

            ShapeFileFeatureLayer housingUnitsLayer = new ShapeFileFeatureLayer(@"../../../Data/Shapefile/Frisco 2010 Census Housing Units.shp");
            LegendAdornmentLayer legend = new LegendAdornmentLayer();

            // Setup the legend adornment
            legend.Title = new LegendItem()
            {
                TextStyle = new TextStyle("Housing Units", new GeoFont("Verdana", 10, DrawingFontStyles.Bold), GeoBrushes.Black)
            };
            legend.Location = AdornmentLocation.LowerRight;
            mapView.AdornmentOverlay.Layers.Add(legend);

            // Project the layer's data to match the projection of the map
            housingUnitsLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(2276, 3857);

            AddClassBreakStyle(housingUnitsLayer, legend);

            // Add housingUnitsLayer to a LayerOverlay
            var layerOverlay = new LayerOverlay();
            layerOverlay.Layers.Add(housingUnitsLayer);

            // Add layerOverlay to the mapView
            mapView.Overlays.Add(layerOverlay);

            // Set the map extent
            housingUnitsLayer.Open();
            mapView.CurrentExtent = housingUnitsLayer.GetBoundingBox();
            housingUnitsLayer.Close();

            mapView.Refresh();
        }

```

Here is the result

 ![image](https://community.thinkgeo.com/uploads/default/original/3X/4/6/46bdab152e0be794f4c88033f25c184e8daca343.png)

You can see the Legend does show up on the lower right of the map. Or I may misunderstand the issue. If you could provide us a small sample to re-produce the issue that will be very helpful for us to look into more details.

Thanks

Frank

---

<div class="post-metadata">

**Author:** ![Clemens\_Ladisch](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/clemens_ladisch/32/25138_2.png) [@Clemens\_Ladisch](https://community.thinkgeo.com/u/Clemens_Ladisch)\
**Post date:** [April 20, 2021, 2:12pm UTC](https://community.thinkgeo.com/t/legendadornmentlayer-not-display/10055/3 "2021-04-20T14:12:16Z")

</div>

The AdornmentOverlay does not notice when new layers are added; you have to re-open it:

```auto
mapView.AdornmentOverlay.Close();
mapView.AdornmentOverlay.Layers.Add(...);
mapView.AdornmentOverlay.Open();

```

---

<div class="post-metadata">

**Author:** ![Frank4](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/frank4/32/25224_2.png) [@Frank4](https://community.thinkgeo.com/u/Frank4)\
**Post date:** [April 20, 2021, 7:40pm UTC](https://community.thinkgeo.com/t/legendadornmentlayer-not-display/10055/4 "2021-04-20T19:40:53Z")

</div>

Thanks Clemens,  
Could you please try with  
mapView.AdornmentOverlay.Refresh();

I may misunderstand your issue. If you could provide us a sample that will be very helpfu.

By the way there is an issue in the V12.3.5 for the AdornmentOverlay. You may need get the latest version which is V12.3.10 and try again.

Thanks

Frank

---

<div class="post-metadata">

**Author:** ![Torsten](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/8e8cbc/32.png) [@Torsten](https://community.thinkgeo.com/u/Torsten)\
**Post date:** [April 21, 2021, 9:22am UTC](https://community.thinkgeo.com/t/legendadornmentlayer-not-display/10055/5 "2021-04-21T09:22:11Z")

</div>

Hallo Frank, hallo Clemens,

Thanks for your suggenstions. In the meantime I changed my code. I load the Adornmentlayers in the map - Load event, and set the visibility accordingly to my needs. When I change the Visibility of the layers, later in code and refresh the map, the results are correct.  
Independently of my changes, I will try your hints.

Regards Torsten

---

<div class="post-metadata">

**Author:** ![Frank4](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/frank4/32/25224_2.png) [@Frank4](https://community.thinkgeo.com/u/Frank4)\
**Post date:** [April 21, 2021, 4:11pm UTC](https://community.thinkgeo.com/t/legendadornmentlayer-not-display/10055/6 "2021-04-21T16:11:10Z")

</div>

Thanks Torsten,  
Good to know it works. Go ahead let us know if you have more question.

Thanks

Frank
