5

I can't get the simple Legend sample working with this florida mapservice and the ESRI Silverlight SDK 2.1.

The names appear, but the tree doesn't get populated.

Anyone see why this code shouldn't work?

Here's my modified xaml:

<esri:Map x:Name="MyMap" Extent="-15000000,2000000,-7000000,8000000">
            <esri:ArcGISTiledMapServiceLayer ID="Street Map" 
                    Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
            <esri:ArcGISDynamicMapServiceLayer ID="Florida" Opacity="0.6" Initialized="ArcGISDynamicMapServiceLayer_Initialized"
                                               InitializationFailed="ArcGISDynamicMapServiceLayer_InitializationFailed"
                    Url="http://map.floridadisaster.org/GIS/rest/services/Facilities/Critical_Facilities/MapServer"/>
        </esri:Map>

        <Border Background="#77919191" BorderThickness="1" CornerRadius="5"
            HorizontalAlignment="Right"  VerticalAlignment="Top"
            Margin="20" Padding="5" BorderBrush="Black" >
            <esri:Legend Map="{Binding ElementName=MyMap}" 
                         LayerIDs="Florida"
                         LayerItemsMode="Tree"                         
                         LayoutUpdated="Legend_LayoutUpdated"
                   BindingValidationError="Legend_BindingValidationError"       />
        </Border>

Running the sample with fiddler, I see a request sent to here: http://www.arcgis.com/sharing/tools/legend?soapUrl=http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer&f=json&returnbytes=true&_ts=634254399369803267

However, no similar request is made when running my modified version.

0

1 Answer 1

3

It is working for me when I change the Legend control reference to ESRI.ArcGIS.Client.Toolkit. I was getting a compiler error when I tried to use the legend from the same namespace as the Map control, which is what they are doing in the sample.

Here is my XAML code:

<UserControl 
         x:Class="SilverlightApplication1.MainPage" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:esri="http://schemas.esri.com/arcgis/client/2009" 
xmlns:esriToolkit="clr-namespace:ESRI.ArcGIS.Client.Toolkit;assembly=ESRI.ArcGIS.Client.Toolkit"

mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">

<Grid x:Name="LayoutRoot" Background="White">
    <esri:Map x:Name="MyMap" Extent="-15000000,2000000,-7000000,8000000">
        <esri:ArcGISTiledMapServiceLayer ID="Street Map"  
                Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
        <esri:ArcGISDynamicMapServiceLayer ID="Florida" Opacity="0.6" Initialized="ArcGISDynamicMapServiceLayer_Initialized" 
                                           InitializationFailed="ArcGISDynamicMapServiceLayer_InitializationFailed" 
                Url="http://map.floridadisaster.org/GIS/rest/services/Facilities/Critical_Facilities/MapServer"/>
    </esri:Map>

    <Border Background="#77919191" BorderThickness="1" CornerRadius="5" 
        HorizontalAlignment="Right"  VerticalAlignment="Top" 
        Margin="20" Padding="5" BorderBrush="Black" >
        <esriToolkit:Legend Map="{Binding ElementName=MyMap}"  
                     LayerIDs="Florida" 
                     LayerItemsMode="Tree"                          
                     LayoutUpdated="Legend_LayoutUpdated" 
               BindingValidationError="Legend_BindingValidationError"       />
    </Border>

</Grid>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.