
The ArcGIS Silverlight API provides a set of pre-defined map layer types to add to a Map control. Layer types include map service layers, such as ArcGIS Server and Bing Maps, feature layers which represent graphic features in layers hosted by an ArcGIS Server map service or tables hosted by MapIt, graphics layers for native graphic feature display, and element layers to include Silverlight UI elements and media on a map.
Layers are added to a Map controls layer's collection via the Layers property. There are a few items to consider when adding layers to a map:

Map service layers come in two varieties, tiled and dynamic. Tiled service layers provide access to a set of map image tiles organized into pre-defined scale levels and hosted on a remote server. Dynamic service layers provide access to map and image services that generate map images on the fly.
The following table lists the map service layer types and descriptions included with the ArcGIS Silverlight API. You will use the layer types to add layers to your Map.
| Service host | Map service layer type | Description |
|---|---|---|
| ArcGIS Server | ArcGISTiledMapServiceLayer |
ArcGIS Server cached map service hosting a set of map image tiles. |
| ArcGISDynamicMapServiceLayer |
ArcGIS Server non-cached map service that generates map images on the fly. Non-cached map services provide dynamic access to both vector and raster data sources. |
|
| ArcGISImageServiceLayer |
ArcGIS Server image service that generates map images on the fly. Image services provide dynamic access to raster data sources. |
|
| Bing Maps | TileLayer | Bing Maps map imagery layer. Provides access to pre-cached roads and aerial imagery. |
Feature layers represent layers that contain features (geometry and attributes) and are hosted by a service. The FeatureLayer type provides a convenient class to reference a feature layer in an ArcGIS Server map service or a spatial table using a MapIt Spatial Data Service. The Url property of a FeatureLayer defines the HTTP endpoint to a service which provides access to the layer or table. Graphic features are retrieved from the service and rendered on the client using graphic capabilities native to the ArcGIS API for Silverlight/WPF. See the FeatureLayer discussion for more information on creating and defining feature layer properties.
The following example shows the XAML markup for a simple Silverlight application that contains an ArcGIS Silverlight API Map control with three different ArcGIS Server map service layers. Use the Creating a map topic for information on how to create a map and reference its layer collection. All ArcGIS Server layer types in the ArcGIS Silverlight API are included in the ESRI.ArcGIS.Client.dll in the ESRI.ArcGIS.Client namespace.
<UserControl x:Class="SilverlightApp.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client">
<Grid x:Name="LayoutRoot" Background="White">
<esri:Map x:Name="MyMap" >
<esri:Map.Layers>
<esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"
Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
<esri:ArcGISImageServiceLayer ID="SanFranciscoImageLayer"
Url="http://serverapps.esri.com/ArcGIS/rest/services/SamplesNET/SanFranciscoImage/MapServer" />
<esri:ArcGISDynamicMapServiceLayer ID="CaliforniaLayer"
Url="http://serverapps.esri.com/ArcGIS/rest/services/California/MapServer" />
</esri:Map.Layers>
</esri:Map>
</Grid>
</UserControl>
When a map service layer is initialized, two properties that store layer specific extents will be available: InitialExtent and FullExtent. Handle the Initialized event on the layer in the code-behind then use either layer extent to define the Map extent. Use the following XAML and code-behind examples as a guide.
XAML
<esri:Map x:Name="MyMap" > <esri:Map.Layers> <esri:ArcGISDynamicMapServiceLayer ID="CaliforniaLayer" Url="http://serverapps.esri.com/ArcGIS/rest/services/California/MapServer" Initialized="CaliforniaLayer_Initialized" />
Code-Behind
private void CaliforniaLayer_Initialized(object sender, EventArgs e)
{
Layer layer = sender as Layer;
MyMap.ZoomTo(layer.InitialExtent);
}
At times, initialization of a layer may fail. This may be caused by any number of issues. Some of the more common problems are:
By default, when a layer fails to initialize, it will not be displayed in a map. To listen for initialization failure, handle the InitializationFailed event and check the exception returned via the layer's InitializationFailure property.
XAML
<esri:Map x:Name="MyMap" > <esri:Map.Layers> <esri:ArcGISDynamicMapServiceLayer ID="CaliforniaLayer" Url="http://serverapps.esri.com/ArcGIS/rest/services/California/MapServer" InitializationFailed="CaliforniaLayer_InitializationFailed" />
Code-Behind
private void CaliforniaLayer_InitializationFailed(object sender, EventArgs e)
{
Layer layer = sender as Layer;
string exceptionMessage = layer.InitializationFailure.Message;
MyTextBlock.Text = exceptionMessage;
}