0

I tried to create a simple webgis with silverlight. Software that I used to make the application: ArcGIS Desktop 10 (without sp), ArcGIS Server 10, Silverlight 4, Microsoft blend 4, and Visual Studio 2010 sp1. We generally use the code below to add layers to map:

<esri:Map x:Name="Map" >
        <esri:Map.Layers>
              <esri:ArcGISDynamicMapServiceLayer ID="samplewebgis" 
                    Url="http://m-pc/arcgis/rest/services/test/MapServer" />        
        </esri:Map.Layers>
  </esri:Map>

But when i use the code, the map legend shows no layers. then I tried the code below:

<esri:Map x:Name="Map"   Grid.RowSpan="3">                                  

      <esri:FeatureLayer  ID="xx" Url="http://m-pc/arcgis/rest/services/test/MapServer/0"/> 
      <esri:FeatureLayer  ID="yy" Url="http://m-pc/arcgis/rest/services/test/MapServer/1" /> 

</esri:Map>

This code works properly and legend show layers. Why can't I use esri:map.layers and why can't the legend show layers of map when I use map.layers?

2 Answers 2

1

Map.Layers refers to the layer collection in the application's code-behind. You don't need the esri:Map.Layers in your xaml code, because it understands that any child item in the esri:Map xml code will be a layer of some kind of layer.

If you want to manage layers in the code-behind, however, you would use Map.Layers.

XAML:

<esri:Map x:Name="Map" >
    <esri:ArcGISDynamicMapServiceLayer ID="samplewebgis" 
          Url="http://m-pc/arcgis/rest/services/test/MapServer" />        
</esri:Map>

Code-behind (VB.net)

Dim myLayer as New ArcGISDynamicMapServiceLayer("http://m-pc/arcgis/rest/services/test2/MapServer")
myLayer.ID = "samplewebgis_2"
Map.Layers.Add(myLayer)
1
  • i try your code but still i have same problem .
    – BBG_GIS
    Commented Nov 20, 2012 at 16:37
0

The first sample is not an ArcGISDynamicMapServiceLayer. It is a tiled map service. Try using <esri:ArcGISTiledMapServiceLayer ...

Writing about spatial software development spatialexception.org

2
  • sorry . i edited my code .
    – BBG_GIS
    Commented Nov 19, 2012 at 20:21
  • i try your code . but have same problem . i also installed sp4 for arcgis desktop 10, arcgis server services,arcgis server web application but map legend does not show anything
    – BBG_GIS
    Commented Nov 20, 2012 at 16:50

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.