arcGis silverlight api 2.1 Legend Control

3370
19
01-02-2011 10:08 PM
rohandontireddy
New Contributor
Hi iam using 2.1 Legend control fopr displaying legends if i use the map service http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapSe... then im getting the legends properly
but if i use my mapservice http://192.168.16.17/ArcGIS/rest/services/DelhiMain10/MapServer im only getting the layers list legends are not getting displayed.
an i missing something in mapservice ?
0 Kudos
19 Replies
JollyJacob
New Contributor
Thanks Dominique. We'll try the Flat mode and if time permits redesign the legend control.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
In case this could help, here is a legend style using only itemscontrols (2 imbricated itemscontrols, one for layer items, one for legend items)
<Style x:Key="ItemsControl" TargetType="esriToolkit:Legend">
    <Setter Property="LayerItemsMode" Value="Flat" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="esriToolkit:Legend">
                <ScrollViewer    Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"   
                        Padding="{TemplateBinding Padding}"
                        >
                    <ItemsControl ItemsSource="{TemplateBinding LayerItemsSource}" 
                                    HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Vertical">
 
                                    <!--Layer Item-->
                                    <ContentPresenter Content="{Binding}" ContentTemplate="{Binding Template}" />
 
                                    <!--Legend Items-->
                                    <ItemsControl ItemsSource="{Binding LegendItems}" >
                                        <ItemsControl.ItemTemplate>
                                            <DataTemplate >
                                                <ContentPresenter Content="{Binding}" ContentTemplate="{Binding Template}" />
                                            </DataTemplate>
 
                                        </ItemsControl.ItemTemplate>
                                    </ItemsControl>
                                </StackPanel>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                        <ItemsPresenter/>
                    </ItemsControl>
                </ScrollViewer>
 
            </ControlTemplate>
 
        </Setter.Value>
    </Setter>
</Style>
0 Kudos
SergioGalindo
New Contributor
Hi Dominique,

Is there any way of changing the legend symbol size?

Thanks,

Sergio
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Hi Sergio,

To change the symbol size you have to change the LegendItemTemplate.

The easiest way is to give a fixed size to the symbol (15 in this sample) :
<esri:Legend.LegendItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,-1">
<Image Source="{Binding ImageSource}" HorizontalAlignment="Center" VerticalAlignment="Center"
                   Stretch="Uniform" Height="15" Width="15" Margin="0,-1" />
<TextBlock Text="{Binding Label}" Margin="5,0,0,0" VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</esri:Legend.LegendItemTemplate>
The side effect due to the uniform stretch is that all symbols will have the same size. This can be an issue if your feature layer rendering is playing with the size of the symbols.
In this case, I guess that one option is to set the image height and width to a ratio of the PixelHeight and PixelWidth of the image source. But this is a little bit complex, there is probably simpler solution, but which one:confused:.
0 Kudos
SergioGalindo
New Contributor
That's exactly what i was looking for.

1000 thanks!!!!!

Sergio
0 Kudos
JuanPoma
New Contributor
hi,

Is there legend link for MapServices in ArcGIS Server for Java Plataform?

I installed ArcGIS SP1 for ArcGIS Server for Java Plataform, and legend link is not shown.

Thanks for your help.
0 Kudos
RobertDolormente
New Contributor
So I've having same issue. Funny thing is it was working earlier. Currently, I have no legend link in services page and no symbology showing up in my app. What do I need to do to get the legend link? I'm running ArcGIS 10.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
At first glance it looks like your server is now using ArcGIS 10 and no more ArcGIS server 10SP1.

You can check the version of your server with a request like this one : http://services.arcgisonline.com/ArcGIS/rest/services. The current version for 10SP1 should be 10.01.
0 Kudos
BabakSekandari1
New Contributor
My Legend control is also not showing the symbology.
I'm using the following control:
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#LegendWithTemplates

I have ArcGIS 9.3.1 SP1.
What does it mean for a layer to be public or private? How can I check / alter that.

Also, when I first added the Legend control to my application, it should the map services and their layers. Now it just shows the map services. It is the same code. Any ideas what might have happened?
0 Kudos
DominiqueBroux
Esri Frequent Contributor

I have ArcGIS 9.3.1 SP1.
What does it mean for a layer to be public or private? How can I check / alter that.



'public' means that anybody from anywhere can access to the Url of your map service.
A typical non public url is : http://localhost/.....
0 Kudos