Back to Devexpress

BingElevationDataProvider Class

windowsforms-devexpress-dot-xtramap-1ae852a5.md

latest7.8 KB
Original Source

BingElevationDataProvider Class

OBSOLETE

This class is obsolete. Microsoft deprecated Bing Maps on June 30th, 2025. For alternative providers, see https://www.devexpress.com/bing-maps-winforms

Provides the capability to obtain the elevation data from the Bing Maps service.

Namespace : DevExpress.XtraMap

Assembly : DevExpress.XtraMap.v25.2.dll

NuGet Package : DevExpress.Win.Map

Declaration

csharp
[Obsolete("This class is obsolete. Microsoft deprecated Bing Maps on June 30th, 2025. For alternative providers, see https://www.devexpress.com/bing-maps-winforms")]
[PreferableMember("BingElevationDataProvider", "", "")]
public class BingElevationDataProvider :
    BingMapDataProviderBase,
    IMouseClickRequestSender
vb
<Obsolete("This class is obsolete. Microsoft deprecated Bing Maps on June 30th, 2025. For alternative providers, see https://www.devexpress.com/bing-maps-winforms")>
<PreferableMember("BingElevationDataProvider", "", "")>
Public Class BingElevationDataProvider
    Inherits BingMapDataProviderBase
    Implements IMouseClickRequestSender

Remarks

Important

On May 21, 2024, Microsoft announced that Bing Maps for Enterprise and its API will be discontinued. Azure Maps will be a single unified enterprise mapping platform available from Microsoft.

To obtain and display map data from Azure Maps, we implemented the following providers:

For information on how to migrate your app from Bing Maps to Azure Maps, see the following help topic: Migrate from Bing Maps to Azure Maps Providers.

If you already have a Bing Maps for Enterprise license, you can keep using the current API. You must transition to the new API by June 30, 2025 (for free/basic licenses) or June 30, 2028 (for enterprise licenses). New licenses will no longer be available after June 30, 2025. Bing Maps will not work with our map controls without a license after that date.

Example

This example demonstrates how to receive elevation information from the Bing Maps service.

To do this, request elevation information using the BingElevationDataProvider.RequestPointsElevations method. Then, display the request result using the BingElevationDataProvider.ElevationsCalculated event handler.

csharp
using DevExpress.XtraMap;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace BingElevationData {
    public partial class Form1 : Form {
        InformationLayer layer { get { return (InformationLayer)mapControl.Layers[1]; } }
        VectorItemsLayer vectorLayer { get { return (VectorItemsLayer)mapControl.Layers[2]; } }
        BingElevationDataProvider provider { get { return (BingElevationDataProvider)layer.DataProvider; } }
        public Form1() {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e) {
            provider.ElevationsCalculated += OnElevationCalculated;
            provider.GenerateLayerItems = false;
            List<GeoPoint> locations = new List<GeoPoint> {
                new GeoPoint(41.145556, -73.995),
                new GeoPoint(36.131389, -95.937222),
                new GeoPoint(36.175, -115.136389)
            };
            provider.RequestPointsElevations(locations);
        }
        void OnElevationCalculated(object sender, ElevationsCalculatedEventArgs e) {
            MapItemStorage storage = new MapItemStorage();
            foreach (ElevationInformation elevationInformation in e.Result.Locations) {
                storage.Items.Add(new MapCallout() {
                    Text = string.Format("{0}\nElevation = {1} m", elevationInformation.Location, elevationInformation.Elevation),
                    Location = elevationInformation.Location
                });
            }
            vectorLayer.Data = storage;
        }
    }
}
vb
Imports DevExpress.XtraMap
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms

Namespace BingElevationData
    Partial Public Class Form1
        Inherits Form

        Private ReadOnly Property layer() As InformationLayer
            Get
                Return CType(mapControl.Layers(1), InformationLayer)
            End Get
        End Property
        Private ReadOnly Property vectorLayer() As VectorItemsLayer
            Get
                Return CType(mapControl.Layers(2), VectorItemsLayer)
            End Get
        End Property
        Private ReadOnly Property provider() As BingElevationDataProvider
            Get
                Return CType(layer.DataProvider, BingElevationDataProvider)
            End Get
        End Property
        Public Sub New()
            InitializeComponent()
        End Sub
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
            AddHandler provider.ElevationsCalculated, AddressOf OnElevationCalculated
            provider.GenerateLayerItems = False
            Dim locations As New List(Of GeoPoint)() From { _
                New GeoPoint(41.145556, -73.995), _
                New GeoPoint(36.131389, -95.937222), _
                New GeoPoint(36.175, -115.136389) _
            }
            provider.RequestPointsElevations(locations)
        End Sub
        Private Sub OnElevationCalculated(ByVal sender As Object, ByVal e As ElevationsCalculatedEventArgs)
            Dim storage As New MapItemStorage()
            For Each elevationInformation As ElevationInformation In e.Result.Locations
                storage.Items.Add(New MapCallout() With {.Text = String.Format("{0}" & ControlChars.Lf & "Elevation = {1} m", elevationInformation.Location, elevationInformation.Elevation), .Location = elevationInformation.Location})
            Next elevationInformation
            vectorLayer.Data = storage
        End Sub
    End Class
End Namespace

Implements

ISupportWebRequest

IMouseClickRequestSender

Inheritance

Object InformationDataProviderBase WebInformationDataProvider BingMapDataProviderBase BingElevationDataProvider

See Also

BingElevationDataProvider Members

GIS Data

DevExpress.XtraMap Namespace