Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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)
share|improve this answer
    
i try your code but still i have same problem . –  wetland Nov 20 '12 at 16:37

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

Writing about spatial software development spatialexception.org

share|improve this answer
    
sorry . i edited my code . –  wetland Nov 19 '12 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 –  wetland Nov 20 '12 at 16:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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