Select to view content in your preferred language

Bing AerialWithLabels not rendering on accelerated Layers collection

1050
7
Jump to solution
09-17-2012 07:43 AM
Labels (1)
AaronMorrisett
Emerging Contributor
I have a bing layer working on accelerated layers, however we have noticed that the LayerStyle = AerialWithLabels will only render when it is added to the regular layer collection.  the section of code that switches the layerstyle is simple and looks like the following.
 
            
   switch (bingType)                 {                     case (BingMapType.Street):                         thisType = TileLayer.LayerType.Road;                         break;                     case (BingMapType.Satellite):                         thisType = TileLayer.LayerType.Aerial;                         break;                     case (BingMapType.Hybrid):                         thisType = TileLayer.LayerType.AerialWithLabels;                         break;                 }                                 _bingLayer = new TileLayer { LayerStyle = thisType, ServerType = ServerType.Production, Token = _config.BingKey, Visible = _baseLayerVisibility, ShowLegend = false };


By this point the _bingLayer has already been added to the acceleratedLayers collection.  Note that switching to aerial and road styles render perfectly.

Any suggestions?

Regards,
    Aaron
0 Kudos
1 Solution

Accepted Solutions
MichaelBranscomb
Esri Frequent Contributor
Hi,

Apologies I didn't remember that it was a bug in the v1.0 release of the SDK (build 396 of the ESRI.ArcGIS.Client.* dlls). It is fixed for the next release.

Cheers

Mike

View solution in original post

0 Kudos
7 Replies
MichaelBranscomb
Esri Frequent Contributor
Hi,

Unfortunately I have not been able to reproduce the problem. Here's the code I'm trying - it should be approximately similar to yours:

Code:
        TileLayer _bingLayer;

        private void BingRadioButton_Checked(object sender, RoutedEventArgs e)
        {
            string layerTypeTag = (string)((RadioButton)sender).Tag;

            ESRI.ArcGIS.Client.Bing.TileLayer.LayerType layerType = null;

            switch (layerTypeTag)
            {
                case ("Road"):
                    layerType = TileLayer.LayerType.Road;
                    break;
                case ("Aerial"):
                    layerType = TileLayer.LayerType.Aerial;
                    break;
                case ("AerialWithLabels"):
                    layerType = TileLayer.LayerType.AerialWithLabels;
                    break;
            }

            if (_map.Layers["_bingLayer"] != null)
            {
                _acceleratedDisplayLayersGroup.ChildLayers.Remove(_bingLayer);
            }

            _bingLayer = new TileLayer 
            { 
                ID="_bingLayer",
                LayerStyle = layerType, 
                ServerType = ServerType.Production,
                Token = "<ENTER TOKEN HERE>", 
                Visible = true, 
                ShowLegend = false 
            };

          _acceleratedDisplayLayersGroup.ChildLayers.Add(_bingLayer);
        }


XAML:
<Grid>
    <esri:Map x:Name="_map" UseAcceleratedDisplay="False">
        <esri:AcceleratedDisplayLayers x:Name="_acceleratedDisplayLayersGroup">

        </esri:AcceleratedDisplayLayers>
    </esri:Map>
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
        <RadioButton x:Name="RoadRadioButton" Checked="BingRadioButton_Checked"
                        Tag="Road" IsChecked="true" Margin="5,0,0,0" 
                        GroupName="Layers" Content="Road" />
        <RadioButton x:Name="AerialRadioButton" Checked="BingRadioButton_Checked"
                        Tag="Aerial" Margin="5,0,0,0"  
                        GroupName="Layers" Content="Aerial" />
        <RadioButton x:Name="AerialWithLabelsRadioButton" Checked="BingRadioButton_Checked" 
                        Tag="AerialWithLabels" Margin="5,0,0,0" 
                        GroupName="Layers" Content="Aerial - Labels"/>
    </StackPanel>
</Grid>


Cheers

Mike
0 Kudos
AaronMorrisett
Emerging Contributor
Thanks for the reply,
  The only difference I notice between our code is that you are removing it from the collection and re-adding it when you switch layer style.  I'll give this a shot and see if it seems to help.

Regards,
    Aaron
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

Just new'ing the layer probably won't trigger the layer initialization - to confirm you could try calling Initialize() on the layer then adding it to the map.

Cheers

Mike
0 Kudos
AaronMorrisett
Emerging Contributor
Are you using the WPF pre-release .dll's that are version 3.0.0.318 or the release version 3.0.0.396.

In the pre-release version I can get all three types of the bing map to display correctly.  However if I use the release dll's I can only get road and aerial to work.

Regards,
   Aaron
0 Kudos
AaronMorrisett
Emerging Contributor
Here is the entire section of code I am using that works if I use pre-release .dll's but not with release .dll's.

XAML:

[HTML]<Window x:Class="esritest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
    <Grid>
        <esri:Map ZoomFactor="1.5" PanDuration="0" ZoomDuration="0" WrapAround="True"  MinimumResolution=".0000001" IsLogoVisible="False" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch"  Name="map1" />


        <GroupBox HorizontalAlignment="Left" VerticalAlignment="Top">
            <Grid>
                <Rectangle Fill="White" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
            <StackPanel Orientation="Horizontal">
            <RadioButton Name="_radioButtonRoad" Content="Road" IsChecked="True" Checked="_radioButtonRoad_Checked" Margin="3"/>
                    <RadioButton Name="_radioButtonAerial" Content="Aerial" Checked="_radioButtonAerial_Checked"  Margin="3"/>
                    <RadioButton Name="_radioButtonAerialWithLabels" Content="Aerial With Labels" Checked="_radioButtonAerialWithLabels_Checked"  Margin="3"/>
            </StackPanel>
            </Grid>
        </GroupBox>

    </Grid>
</Window>[/HTML]

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ESRI.ArcGIS.Client.Bing;
using ESRI.ArcGIS.Client;

namespace esritest
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        TileLayer _bingLayer;
        AcceleratedDisplayLayers _acceleratedDisplayLayersGroup = new AcceleratedDisplayLayers();
        public MainWindow()
        {
            InitializeComponent();
            
            Loaded += new RoutedEventHandler(MainWindow_Loaded);
        }
        bool _loaded = false;
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            map1.Layers.Add(_acceleratedDisplayLayersGroup);
            if (map1.Layers["_bingLayer"] != null)
            {
                _acceleratedDisplayLayersGroup.ChildLayers.Remove(_bingLayer);
            }

            _bingLayer = new TileLayer
            {
                ID = "_bingLayer",
                LayerStyle = TileLayer.LayerType.Road,
                ServerType = ServerType.Production,
                Token = "My Key",
                Visible = true,
                 //ShowLegend = false
            };
            _bingLayer.Initialize();
            _acceleratedDisplayLayersGroup.ChildLayers.Add(_bingLayer);
            _loaded = true;
        }

        private void _radioButtonRoad_Checked(object sender, RoutedEventArgs e)
        {
            if (_loaded)
            {
                _acceleratedDisplayLayersGroup.ChildLayers.Remove(_bingLayer);
                _bingLayer = null;
                _bingLayer = new TileLayer
                {
                    ID = "_bingLayer",
                    LayerStyle = TileLayer.LayerType.Road,
                    ServerType = ServerType.Production,
                    Token = "My Key",
                    Visible = true,
                };
                _bingLayer.Initialize();
                _acceleratedDisplayLayersGroup.ChildLayers.Add(_bingLayer);
            }
        }

        private void _radioButtonAerial_Checked(object sender, RoutedEventArgs e)
        {
            if (_loaded)
            {
                _acceleratedDisplayLayersGroup.ChildLayers.Remove(_bingLayer);
                _bingLayer = null;
                _bingLayer = new TileLayer
                {
                    ID = "_bingLayer",
                    LayerStyle = TileLayer.LayerType.Aerial,
                    ServerType = ServerType.Production,
                    Token = "My Key",
                    Visible = true,
                };
                _bingLayer.Initialize();
                _acceleratedDisplayLayersGroup.ChildLayers.Add(_bingLayer);
            }
        }

        private void _radioButtonAerialWithLabels_Checked(object sender, RoutedEventArgs e)
        {
            if (_loaded)
            {
                _acceleratedDisplayLayersGroup.ChildLayers.Remove(_bingLayer);
                _bingLayer = null;
                _bingLayer = new TileLayer
                {
                    ID = "_bingLayer",
                    LayerStyle = TileLayer.LayerType.AerialWithLabels,
                    ServerType = ServerType.Production,
                    Token = "My Key",
                    Visible = true,
                };
                _bingLayer.Initialize();
                _acceleratedDisplayLayersGroup.ChildLayers.Add(_bingLayer);
            }
        }
    }
}
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

Apologies I didn't remember that it was a bug in the v1.0 release of the SDK (build 396 of the ESRI.ArcGIS.Client.* dlls). It is fixed for the next release.

Cheers

Mike
0 Kudos
AaronMorrisett
Emerging Contributor
Thank you sir, I'll look for it in the next release.

Regards,
   Aaron
0 Kudos