Select to view content in your preferred language

Switching Esri:ArcGISTiledMapServiceLaye, Bing:TileLayer and esri:OpenStreetMapLayer

850
4
03-14-2011 02:42 PM
FranciscoRodriguez1
Emerging Contributor
Hi,


Any body know how switching Esri, bing and OpenStreetMap in the same Map.Layers project? and show ever layer with only buttonradio cl¡c.

<esri:Map.Layers>
<esri:ArcGISTiledMapServiceLayer x:Name="TileMap" Url="http://maps.location-world.com/ArcGIS/rest/services/globalmapservice/MapServer" />
<Bing:TileLayer ID="BingLayer" LayerStyle="Road" Visible="False" ServerType="Production"
                   Token="Aoz7s-1dmOt1cit9hG7sPQcLz9O-MYXN4YRFIs8vph0NeHC_ya9goydUOtOpvZ9X"/>
<esri:OpenStreetMapLayer ID="OSMLayer" Style="Mapnik"   Visible="False"/>
<esri:GraphicsLayer ID="MyGraphicsLayer"/>
</esri:Map.Layers>

Thank's for all.
0 Kudos
4 Replies
JenniferNery
Esri Regular Contributor
You can do something similar to this: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SwitchMap but instead of RadioButton.Tag contain the URL string, have it contain resource key.

XAML-code:
<Grid.Resources>
 <esri:ArcGISTiledMapServiceLayer x:Key="MyTiledLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
 <bing:TileLayer x:Key="MyBingLayer" LayerStyle="Road" Visible="True" ServerType="Production" Token="{StaticResource BingKeyString}" />
 <esri:OpenStreetMapLayer x:Key="MyOpenStreetMapLayer" Style="Mapnik" />
</Grid.Resources>


Code-behind:
private void RadioButton_Click(object sender, RoutedEventArgs e)
{
 MyMap.Layers.Clear();
 Layer layer = this.LayoutRoot.Resources[(sender as RadioButton).Tag] as Layer;
 MyMap.Layers.Add(layer);
}
0 Kudos
FranciscoRodriguez1
Emerging Contributor
Thank you, very much
0 Kudos
FranciscoRodriguez1
Emerging Contributor
Jennifer,

I writed:

Mimapa.Layers.Clear();
           Layer layer = this.LayoutRoot.Resources["MyBingLayer"] as Layer;
           Mimapa.Layers.Add(layer);
and only Show white screen. What is it the problem?
0 Kudos
dotMorten_esri
Esri Notable Contributor
You could also just flip the Visible property on the two layers, and have them both added to the map up front. If you switch back and forth a lot, this would save you several layer iniitializations.
0 Kudos