Click or drag to resize
BingLayer Class
Bing Maps for Enterprise Tile Layer.
Inheritance Hierarchy

Namespace: Esri.ArcGISRuntime.Layers
Assembly: Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: (
public sealed class BingLayer : TiledMapServiceLayer, 
	IQueryCopyright, ICopyright

The BingLayer type exposes the following members.

Public methodBingLayer
Initializes a new instance of the BingLayer class.
Public methodBingLayer(String)
Creates a new instance of the BingLayer class.
Public methodCheckAccess
Determines whether the calling thread has access to this DispatcherObject.
(Inherited from DispatcherObject.)
Public methodClearValue(DependencyProperty)
Clears the local value of a property. The property to be cleared is specified by a DependencyProperty identifier.
(Inherited from DependencyObject.)
Public methodClearValue(DependencyPropertyKey)
Clears the local value of a read-only property. The property to be cleared is specified by a DependencyPropertyKey.
(Inherited from DependencyObject.)
Public methodCoerceValue
Coerces the value of the specified dependency property. This is accomplished by invoking any CoerceValueCallback function specified in property metadata for the dependency property as it exists on the calling DependencyObject.
(Inherited from DependencyObject.)
Public methodEquals
Determines whether a provided DependencyObject is equivalent to the current DependencyObject.
(Inherited from DependencyObject.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Gets a hash code for this DependencyObject.
(Inherited from DependencyObject.)
Public methodGetLocalValueEnumerator
Creates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject.
(Inherited from DependencyObject.)
Protected methodGetTileDataAsync
Gets the tile data.
(Inherited from TiledMapServiceLayer.)
Protected methodGetTileUriAsync
Returns the Uri for a tile at a given row, column and level.
(Overrides TiledMapServiceLayerGetTileUriAsync(Int32, Int32, Int32, CancellationToken).)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetValue
Returns the current effective value of a dependency property on this instance of a DependencyObject.
(Inherited from DependencyObject.)
Public methodCode exampleInitializeAsync
Loads the metadata for this layer based on the current configuration.
(Inherited from Layer.)
Protected methodInvalidate
Causes tiled layer to clear tiles.
(Inherited from TiledLayer.)
Public methodInvalidateProperty
Re-evaluates the effective value for the specified dependency property
(Inherited from DependencyObject.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnInitializeTiledLayerRequestedAsync
Override this method to initialize any properties and settings prior to using the map.
(Overrides TiledLayerOnInitializeTiledLayerRequestedAsync.)
Protected methodOnPropertyChanged(DependencyPropertyChangedEventArgs)
Invoked whenever the effective value of any dependency property on this DependencyObject has been updated. The specific dependency property that changed is reported in the event data.
(Inherited from DependencyObject.)
Protected methodOnPropertyChanged(String)
Notifies listeners that a property value has changed.
(Inherited from Layer.)
Public methodReadLocalValue
Returns the local value of a dependency property, if it exists.
(Inherited from DependencyObject.)
Public methodSetCurrentValue
Sets the value of a dependency property without changing its value source.
(Inherited from DependencyObject.)
Protected methodSetLayerInitializationFailed
status must be failed - if not throw
(Inherited from Layer.)
Protected methodSetLayerStatus
Status cannot be failed or it will throw. To set Status to LayerStatus.Failed, call SetLayerInitializationFailed.
(Inherited from Layer.)
Public methodSetValue(DependencyProperty, Object)
Sets the local value of a dependency property, specified by its dependency property identifier.
(Inherited from DependencyObject.)
Public methodSetValue(DependencyPropertyKey, Object)
Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property.
(Inherited from DependencyObject.)
Protected methodShouldSerializeProperty
Returns a value that indicates whether serialization processes should serialize the value for the provided dependency property.
(Inherited from DependencyObject.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodVerifyAccess
Enforces that the calling thread has access to this DispatcherObject.
(Inherited from DispatcherObject.)
Public fieldStatic memberCultureProperty
Identifies the Culture Dependency Property
Public fieldStatic memberKeyProperty
Identifies the Key Dependency Property
Public fieldStatic memberMapStyleProperty
Identifies the MapStyle Dependency Property
Public propertyBrightness
Gets or sets layer brightness level.
(Inherited from TiledLayer.)
Public propertyContrast
Gets or sets layer contrast level.
(Inherited from TiledLayer.)
Public propertyCulture
Gets or sets the culture used for getting localized labels.
Public propertyDefaultSpatialReference
Gets the default spatial reference.
(Inherited from Layer.)
Public propertyDependencyObjectType
Gets the DependencyObjectType that wraps the CLR type of this instance. 
(Inherited from DependencyObject.)
Public propertyDispatcher
Gets the Dispatcher this DispatcherObject is associated with.
(Inherited from DispatcherObject.)
Public propertyDisplayName
Gets or sets the display name.
(Inherited from Layer.)
Public propertyFullExtent
Gets the full extent of the layer in it's default spatial reference.
(Inherited from Layer.)
Public propertyGamma
Gets or sets layer gamma level.
(Inherited from TiledLayer.)
Public propertyID
Gets or sets an ID associated with this layer.
(Inherited from Layer.)
Public propertyInitializationException
Gets the initialization exception.
(Inherited from Layer.)
Public propertyIsSealed
Gets a value that indicates whether this instance is currently sealed (read-only).
(Inherited from DependencyObject.)
Public propertyIsVisible
Gets or sets the layer visibility.
(Inherited from Layer.)
Public propertyKey
Gets or sets the bing application key.
Public propertyMapStyle
Gets or sets the layer style
Public propertyMaxScale
Gets or sets the maximum scale to display this layer at. A small number allows the map to display the layer when zooming further in.
(Inherited from Layer.)
Public propertyMinScale
Gets or sets the minimum scale to render this layer at. A large number allows the map to display the layer when zooming further out.
(Inherited from Layer.)
Public propertyOpacity
Gets or sets the opacity.
(Inherited from Layer.)
Public propertyResamplingMode
Gets or sets the resampling mode.
(Inherited from TiledLayer.)
Public propertyShowLegend
Gets or sets a value indicating whether this layer should show in a legend
(Inherited from Layer.)
Public propertyStatus
The Layer's Status, indicating whether it is being/has been initialized, or initialization failed.
(Inherited from Layer.)
Public propertyTileInfo
Gets the tiling scheme.
(Inherited from TiledLayer.)
Public eventPropertyChanged
Occurs when a property value changes.
(Inherited from Layer.)

The Bing Maps TileLayer requires you to first get a Bing Maps Key from Microsoft. This key can be acquired at Set the Key property to the generated key.

The Bing Maps tile layer requires the map to use the WebMercator projection (WKID=102100). You can use the Esri.ArcGISRuntime.GeometryEngine.Project method to convert coordinates between WGS84 longitude/latitude values (WKID=4326) and WebMercator.

The Culture property allows you to set the label language for the tiles returned, and defaults to US English ("en-US"). See Returning localized results for a list of cultures that support map labels.

XAML usage of Bing Maps TileLayer:

  <esri:BingLayer ID="RoadMap" Key="INSERT-YOUR-BING-KEY-HERE" MapStyle="AerialWithLabels" Culture="en-US"/>


Teaches one method (advanced) for using the Microsoft WebClient and a DataContract to poll a Microsoft Bing development server to determine if a Bing Key is correct and then loading multiple BingLayer's into the Map and allowing the user to switch between various BingLayer.MapStyles.

Shows adding a BingLayer and alternating between various BingLayer.MapStyles.

<Window x:Class="BingLayer_Advanced.MainWindow"
    Title="MainWindow" Height="600" Width="800">

        <!-- Add a MapView Control with an empty Map. -->
            <esri:Map x:Name="Map1" />

        Add a set of controls to have the user supply a Bing Key 64+ character string. When the user believes they have supplied the correct Bing Key string
        the 'Load Map' button will enable so the user can click it to render various BingLayers in the map. If the user does not have a Bing Key, then they 
        can click the 'Get Bing Key' button to obtain one from Microsoft. This set of controls is visible when the application is first loaded and then goes
        away when user enters the correct Bing Key. 
        <Border Name="BingKeyGrid" BorderBrush="Black" BorderThickness="1" Background="White" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10">
            <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="10">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2" >
                    <TextBlock FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Text="Enter Bing Key" Margin="2" Foreground="Black" />
                    <Button Margin="2" Content="Get Bing Key" Click="Button_Click"/>
                <TextBox x:Name="BingKeyTextBox" Width="250" HorizontalAlignment="Right" Margin="0,2,0,2" TextChanged="BingKeyTextBox_TextChanged" />
                <TextBlock Name="InvalidBingKeyTextBlock" Text="Invalid Key" Foreground="Red" Margin="0,2,0,2" HorizontalAlignment="Center" Visibility="Collapsed"/>
                <Button Name="LoadMapButton" Content="Load Map" Width="100" Margin="0,5,0,10" IsEnabled="False" HorizontalAlignment="Center" Click="LoadMapButton_Click" />

        Add RadioButtons; one for each different MapStyle of BingLayer that is supported. The RadioButton.Tag property contains
        the string name of the BingLayer.MapStyle; this will be used in the code behind to turn on/off the visibility of the 
        various BingLayer's that are loaded. The same RadioButton.Click event is used to switch between the BingLayers. 
        NOTE: By default, these entire set of controls have their visibility set to collapsed and will not appear to the user
        unless the correct BingLayer.Key is supplied.
        <Border Name="LayerStyleGrid" BorderBrush="Black" BorderThickness="1" Background="White" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10" Visibility="Collapsed">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="5">
                <RadioButton x:Name="RoadRadioButton" Tag="Road" IsChecked="true" Margin="5,0,0,0" GroupName="Layers" Content="Road" Click="RadioButton_Click"/>
                <RadioButton x:Name="AerialRadioButton" Tag="Aerial" Margin="5,0,0,0" GroupName="Layers" Content="Aerial" Click="RadioButton_Click"/>
                <RadioButton x:Name="AerialWithLabelsRadioButton" Tag="AerialWithLabels" Margin="5,0,0,0" GroupName="Layers" Content="Aerial - Labels" Click="RadioButton_Click"/>


SPECIAL NOTE: The XAML displayed above comes from a C# project. If you are a VB.NET developer, you will need to modify the text for the x:Class namespace from "BingLayer_Advanced.MainWindow" to be just "MainWindow".

// NOTE: You will need to add a Reference to the System.Runtime.Serialization.Json Assembly in your Visual Studio project.

namespace BingLayer_Advanced
    public partial class MainWindow : System.Windows.Window
        public MainWindow()

        private void RadioButton_Click(object sender, System.Windows.RoutedEventArgs e)
            // This function turns on/off the various BingLayer's loaded in the Map based upon user interactions with the RadioButtons.

            // Get the string version of the BingLayer.MapStyle from the RadioButton.Tag property.
            System.Windows.Controls.RadioButton myRadioButton = ((System.Windows.Controls.RadioButton)sender);
            string myLayerNameTag = System.Convert.ToString(myRadioButton.Tag);

            // Loop through the LayerCollection and turn off the visibility of all the BingLayers.
            foreach (Esri.ArcGISRuntime.Layers.Layer oneLayer in Map1.Layers)
                if (oneLayer is Esri.ArcGISRuntime.Layers.BingLayer)
                    oneLayer.IsVisible = false;

            // Turn on the visibility of the BingLayer that matches the RadioButton that was just clicked.
            Esri.ArcGISRuntime.Layers.LayerCollection myLayerCollection = Map1.Layers;
            Esri.ArcGISRuntime.Layers.BingLayer myBingLayer = (Esri.ArcGISRuntime.Layers.BingLayer)myLayerCollection[myLayerNameTag];
            myBingLayer.IsVisible = true;

        private void BingKeyTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
            // This function enabled the 'Load Map' button when a 64+ character BingLayer.Key is entered.

            // Only enable the 'Load Map' button when the user enter Bing Key string is greater than 64 characters in length.
            System.Windows.Controls.TextBox myTextBox = (sender as System.Windows.Controls.TextBox);
            if ((myTextBox.Text.Length) >= 64)
                LoadMapButton.IsEnabled = true;
                LoadMapButton.IsEnabled = false;

        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
            // Launch an Internet Explorer web browser and point the Url to the Microsoft Bing web site for the user to obtain a Bing Key.
            System.Diagnostics.Process.Start("IExplore.exe", "");

        private void LoadMapButton_Click(object sender, System.Windows.RoutedEventArgs e)
            // This function occurs when the user clicks the 'Load Map' button. Using the standard Microsoft WebClient control, attempt to access the Bing Map's
            // developer web server to determine if the Bing Key entered is valid. A custom JSON DataContract is used to read the response from the Bing Map's 
            // development web server to determine if the 'ValidCredentials' JSON syntax is returned for the Bing Key provided by the user. If the Bing Key
            // credentials are valid, then all the BingLayer.MapStyle type of services are loaded into the Map's LayerCollection, as well as hiding the controls 
            // to force the user to enter the Bing Key. 

            // Create a new instance of the Microsoft WebClient control. 
            System.Net.WebClient myWebClient = new System.Net.WebClient();

            // Construct a Url with the Bing Key as a argument pair to contact the Microsoft development Bing web server. 
            string myUri = string.Format("{0}", BingKeyTextBox.Text);

            // Wire up an Event Handler on the WebClient Control to execute when web request is completed.
            myWebClient.OpenReadCompleted += (s, a) =>
                if (a.Error == null)
                    // There was no error returned from the WebClient.OpenReadCompleted call.

                    // Create a new DataContractJsonSerializer using our custom BingAuthentication DataContract defined at the end of this class file. 
                    System.Runtime.Serialization.Json.DataContractJsonSerializer mySerializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(BingAuthentication));

                    // Set the result of the DataContractJsonSerializer.ReadObject to our custom BigAuthentication DataContract.
                    BingAuthentication myBingAuthentication = mySerializer.ReadObject(a.Result) as BingAuthentication;

                    // Close the IOStream of the WebClient.DownloadDataAsync method call.

                    // Get the BingAuthentication.AuthenticationResultCode string from the DataContract.
                    string myAuthenticationResult = myBingAuthentication.AuthenticationResultCode.ToString();

                    // Test if the BingAuthentication.AuthenticationResultCode equals the string 'ValidCredentials'
                    if (myAuthenticationResult == "ValidCredentials")
                        // We did get back the string 'ValidCredentials' from the WebClient request to the development Microsoft Bing web site.

                        // Get the Enumerations of BingLayer.MapStyle types of Bing maps that are available from Microsoft.
                        System.Array myBingLayerTypes = System.Enum.GetValues(typeof(Esri.ArcGISRuntime.Layers.BingLayer.LayerType));
                        int[] myLayerTypes = (int[])myBingLayerTypes;

                        // Loop through each BingLayer.MapStyle enumeration value (an Integer). 
                        foreach (Esri.ArcGISRuntime.Layers.BingLayer.LayerType myLayerType in myLayerTypes)
                            // Create a new BingLayer and set the various properties (.ID, .MapStyle, .Key, and .IsVisible)
                            Esri.ArcGISRuntime.Layers.BingLayer myBingLayer = new Esri.ArcGISRuntime.Layers.BingLayer();
                            myBingLayer.ID = myLayerType.ToString();
                            myBingLayer.MapStyle = myLayerType;
                            myBingLayer.Key = BingKeyTextBox.Text;
                            myBingLayer.IsVisible = false;

                            // Add each of the different Bing maps types to the Map's LayerCollection.

                        // Make the first BingLayer in the BingLayer() array be the one that is visible to the user.
                        Map1.Layers[0].IsVisible = true;

                        // Hide the controls that the user has to enter the Bing Key.
                        BingKeyGrid.Visibility = System.Windows.Visibility.Collapsed;
                        InvalidBingKeyTextBlock.Visibility = System.Windows.Visibility.Collapsed;

                        // Show the RadioButton controls that allow the user to switch between viewing the different BingLayer types.
                        LayerStyleGrid.Visibility = System.Windows.Visibility.Visible;
                        // We did NOT get back the string 'ValidCredentials' from the WebClient request to the development Microsoft Bing web site.
                        // Keep the set of controls prompting the user for a valid Bing Key.

                        InvalidBingKeyTextBlock.Visibility = System.Windows.Visibility.Visible;
                    // There WAS an error returned from the WebClient.OpenReadCompleted call. 
                    // Keep the set of controls prompting the user for a valid Bing Key.

                    InvalidBingKeyTextBlock.Visibility = System.Windows.Visibility.Visible;

            // Call the WebClient.OpenReadAsync Method using the Uri constructed above. This will cause the above in-line WebClient.OpenReadCompleted Event fire. 
            myWebClient.OpenReadAsync(new System.Uri(myUri));

        // Create a custom BingAuthentication class that can be used to hold JSON serializable information from the WebClient. We will use this to see if
        // we get back the string 'ValidCredentials' from a Microsoft Bing development web server for a specific Bing Key provided by the user.
        public class BingAuthentication
            [System.Runtime.Serialization.DataMember(Name = "authenticationResultCode")]
            public string AuthenticationResultCode { get; set; }
See Also
Supported Platforms
This type is supported on the following ArcGIS Runtime .NET SDK platforms:
Windows Desktop
Windows Phone
Windows Store
Additional Examples
Hyperlink to ExampleDescription
ArcGISImageServiceLayerWindowShows creating an ArcGIS Image Service Layer and applying rendering rules.
BingLayer_AdvancedTeaches one method (advanced) for using the Microsoft WebClient and a DataContract to poll a Microsoft Bing development server to determine if a Bing Key is correct and then loading multiple BingLayer's into the Map and allowing the user to switch between various BingLayer.MapStyles.