Select to view content in your preferred language

Remove root element of Legend

4475
13
07-12-2012 08:28 AM
by Anonymous User
Not applicable
Original User: miri

Hi everybody,

The legend issues never end....

I have two tabs: one for layers and one for legend.
Layer tab looks like this:

          <sdk:TabItem Header="Layers" Name="LayersTab" Margin="0,0,0,0">
                <Grid>
                    <esri:Legend LayerItemsMode="Tree" x:Name="MyLegend" Map="{Binding ElementName=Map}"
                                 LegendItemTemplate="{x:Null}" Refreshed="Legend_Refreshed"
                                 LayerIDs="USAID_Layers" ShowOnlyVisibleLayers="false">
                        <esri:Legend.LayerTemplate>
                            <DataTemplate>
                                <!--Layer Item-->
                                <StackPanel x:Name="checkBoxName" Orientation="Horizontal">
                                    <!-- Two overlapping checkboxes, the second checkbox is grayed when the layer is not visible-->
                                    <Grid VerticalAlignment="Center">
                                        <CheckBox IsChecked="{Binding IsEnabled, Mode=TwoWay}" />
                                        <CheckBox IsChecked="{Binding IsEnabled}" IsEnabled="{Binding IsVisible}" IsHitTestVisible="False" />
                                    </Grid>
                                     <TextBlock Text="{Binding Label}" Tag="{Binding SubLayerID}" VerticalAlignment="Center" Margin="2,0,0,0" MouseLeftButtonDown="ClickOnLayerName" />
                                </StackPanel>
                            </DataTemplate>

                        </esri:Legend.LayerTemplate>

                    </esri:Legend>

                </Grid>
            </sdk:TabItem>


Legend tab looks like this:
     
     <sdk:TabItem Header="Legend" Name="LegendTab">
                <Grid>
                    <esri:Legend Map="{Binding ElementName=Map}"
                         LayerItemsMode="Tree"
                        LayerIDs="USAID_Layers"
                        ShowOnlyVisibleLayers="True">
                    </esri:Legend>

                </Grid>
            </sdk:TabItem>


Enclosed with pictures to show how it looks like.
What I was asked is :
1. Remove the root element usaid_layers so it will show more data to the left
2. shrink the spaces from one layerItem to another in the legend tab.

Is that posiible? If yes, how?

Any help will be appreciated.

Thanks a lot,
Miri
0 Kudos
13 Replies
by Anonymous User
Not applicable
Original User: dbroux

The feature layer is added but without the checkbox (only the name). Why?


You have to redefine the MapLayerTemplate as well as in this sample.

MapLayerTemplate is used for all main layers (Featurelayer, ArcGISDynamicMapServiceLayer, KmlLayer, .....)
The LayerTemplate is used for the sublayers of a main layer only.

My feature layer is a cluster layer. Its default legend looks like in the attached image.
Is it possible to show more detailed legend, not only the FlareClusterer?

If you associate a renderer to your feature layer (used when the graphics are not clustered), the legend should be the concatenation of the renderer and of the flareclusterer.
0 Kudos
TanyaOwens
Frequent Contributor
Hello,

My problem is similar to the discussion in this thread. I am using this sample: http://resources.arcgis.com/en/help/silverlight-api/samples/start.htm#LegendWithTemplates with the Showcase Template. I have several layers grouped together from one dynamic map service layer and one feature layer (for using InfoWindow). I would like my legend to show the feature layer and the service layer together without the service layer ID showing in the legend. I am having trouble figuring out where/how to change this in the code.

Thanks!
0 Kudos
by Anonymous User
Not applicable
Original User: miri

Hi Domonique,

1. As to the first problem, I added the MapLayerTemplate and it works fine.
You have to redefine the MapLayerTemplate as well as in this sample.

MapLayerTemplate is used for all main layers (Featurelayer, ArcGISDynamicMapServiceLayer, KmlLayer, .....)
The LayerTemplate is used for the sublayers of a main layer only.


If you associate a renderer to your feature layer (used when the graphics are not clustered), the legend should be the concatenation of the renderer and of the flareclusterer.


2. Can you elaborate more on how to associate a renderer to my featureLayer?
My code is:
                  <esri:FeatureLayer.Clusterer>
                        <esri:FlareClusterer FlareBackground="Orange" FlareForeground="Black" MaximumFlareCount="9" />
                    </esri:FeatureLayer.Clusterer>
I want to show the circles (like in the attached image) to the legend. Do I add a SimpleMarkerSymbols in different sizes?
Where do I add it?

Thanks,
Miri
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Sorry I though you wanted the symbology of individual graphics in the Legend

Now I see. You want the symbol for large clusters.
There is nothing out of the box to do it. However you can add by code one (or more) legend Items in the event Legend.Refreshed.
To create a new legend item, you need basically, the label and the image that you want to see in the legend.
0 Kudos