Hello gentlemen, my name is Djonatas, I am developing a portal using ESRI Silverlight API, I'm trying to change the BaseMap at runtime, or want to have the option to change the base map of Bing by ESRI or otherwise but in time exeução of the logic I'm using now is to remove the layer and create another layer. Below code snippet that I'm implementing.C# private void esriBtn_Click(object sender, RoutedEventArgs e)
{
Map001.Layers.Remove(Map001.Layers["bing_map"]);
var esriLayer = new ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer();
esriLayer.Url = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer";
esriLayer.ID = "esri_layer";
Map001.Layers.Add(esriLayer);
}
private void bingBtn_Click(object sender, RoutedEventArgs e)
{
Map001.Layers.Remove(Map001.Layers["esri_layer"]);
var bingLayer = new ESRI.ArcGIS.Client.Bing.TileLayer();
bingLayer.Token = "My Bing Key";
bingLayer.ID = "bing_map";
Map001.Layers.Add(bingLayer);
}
XAML: <Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Center">
<Button Content="ESRI" x:Name="esriBtn" Click="esriBtn_Click" />
<Button Content="BING" x:Name="bingBtn" Margin="10,0,0,0" Click="bingBtn_Click" />
</StackPanel>
<esri:Map Name="Map001" Grid.Row="1"/>
</Grid>
My problem is: If I click ESRI first it loads normally but can not switch to BING. If I click on BING first it loads normally but can not switch to the ESRI. I saw an example that works perfectly that it is in ArcGIS Viewer for Silverlight when it creates the project have the option of choosing the base map, during this process I can switch between them, I do the same thing but in a normal application. I hope you can help me solve my problem Sorry for my poor English graciously Djonatas Tenfen