/// <summary> Extension method which adds a Microsoft Bing layer to the map. </summary>
        /// <param name="wpfMap"> The map to add the layer to. </param>
        /// <param name="name"> The name of the layer. </param>
        /// <param name="idx"> The index of the layer in the layer hierarchy. </param>
        /// <param name="bingKey"> The Microsoft Bing key to use. </param>
        /// <param name="set"> The imagery set to be used. </param>
        /// <param name="version"> The Microsoft Bing version. </param>
        /// <param name="isBaseMapLayer"> Specifies if the added layer should act as a base layer. </param>
        /// <param name="opacity"> The initial opacity of the layer. </param>
        /// <param name="icon"> The icon of the layer used within the layer gadget. </param>
        /// <param name="copyrightImagePanel"> The panel where the bing logo should be added. </param>
        public static void AddBingLayer(this WpfMap wpfMap, string name, int idx, string bingKey, BingImagerySet set, BingMapVersion version,
                                        bool isBaseMapLayer, double opacity, BitmapImage icon, Panel copyrightImagePanel)
        {
            var metaInfo = new BingMetaInfo(set, version, bingKey);

            // add a bing aerial layer
            var bingLayer = new TiledLayer(name)
            {
                TiledProvider  = new BingTiledProvider(metaInfo),
                IsBaseMapLayer = isBaseMapLayer,
                Opacity        = opacity,
                Icon           = icon
            };

            wpfMap.Layers.Insert(idx, bingLayer);

            try
            {
                var bingLogo = new Image
                {
                    Stretch             = Stretch.None,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Source = new BitmapImage(new Uri(metaInfo.LogoUri))
                };

                copyrightImagePanel.Children.Add(bingLogo);
                copyrightImagePanel.Visibility = Visibility.Visible;
            }
            catch (Exception)
            {
                //Just silently catch exceptions if the image cannot be displayed!
            }
        }
 /// <summary> Initializes a new instance of the <see cref="BingTiledProvider"/> class. </summary>
 /// <param name="metaInfo"> Meta information of the tile provider like minimum and maximum zoom and url. </param>
 public BingTiledProvider(BingMetaInfo metaInfo)
 {
     this.metaInfo = metaInfo;
 }