Back to Devexpress

MapWebRequestEventArgs.Uri Property

wpf-devexpress-dot-xpf-dot-map-dot-mapwebrequesteventargs-791632c4.md

latest4.9 KB
Original Source

MapWebRequestEventArgs.Uri Property

Get the URI of the Internet resource associated with the map web request.

Namespace : DevExpress.Xpf.Map

Assembly : DevExpress.Xpf.Map.v25.2.dll

NuGet Package : DevExpress.Wpf.Map

Declaration

csharp
public Uri Uri { get; }
vb
Public ReadOnly Property Uri As Uri

Property Value

TypeDescription
Uri

A Uri object.

|

Example

This example shows how you can implement a custom proxy to make a request for map tiles from the Bing Maps web service.

To customize a web request, handle the MapImageDataProviderBase.WebRequest event. Then, use the web request arguments to specify your custom map request settings (e.g., custom MapWebRequestEventArgs.Credentials, MapWebRequestEventArgs.Headers for a proxy, etc.) to the Bing Maps data provider.

xaml
<Window 
    x:Class="WebRequest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <dxm:MapControl Name="mapControl1" >
            <dxm:ImageTilesLayer x:Name="imageTilesLayer">
                <dxm:ImageTilesLayer.DataProvider>
                    <dxm:BingMapDataProvider BingKey="INSERT_YOUR_BING_KEY_HERE"   
                                             WebRequest="BingMapDataProvider_WebRequest"/>
                </dxm:ImageTilesLayer.DataProvider>
            </dxm:ImageTilesLayer>
            <dxm:VectorLayer>
                <dxm:MapDot Location="54.196353,37.611622" Size="10"/>
            </dxm:VectorLayer>
        </dxm:MapControl>
    </Grid>
</Window>
vb
Imports System
Imports System.Windows
Imports System.Net
Imports DevExpress.Xpf.Map
Imports System.Globalization
Namespace WebRequest

    Partial Public Class MainWindow
        Inherits Window

        Public Sub New()
            InitializeComponent()

        End Sub

        Private Sub BingMapDataProvider_WebRequest(ByVal sender As Object, ByVal e As MapWebRequestEventArgs)
            e.Proxy = proxy
        End Sub

        Private proxy As New MyProxy()

        Public Class MyProxy
            Implements IWebProxy

            Private credentials_Renamed As ICredentials

            Public Property Credentials() As ICredentials Implements IWebProxy.Credentials
                Get
                    Return credentials_Renamed
                End Get
                Set(ByVal value As ICredentials)
                    credentials_Renamed = value
                End Set
            End Property

            Public Function GetProxy(ByVal destination As Uri) As Uri Implements IWebProxy.GetProxy
                Return destination
            End Function

            Public Function IsBypassed(ByVal host As Uri) As Boolean Implements IWebProxy.IsBypassed
                Return True
            End Function
        End Class

    End Class
End Namespace
csharp
using System;
using System.Windows;
using System.Net;
using DevExpress.Xpf.Map;
using System.Globalization;
namespace WebRequest {

    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();

        }

        private void BingMapDataProvider_WebRequest(object sender, MapWebRequestEventArgs e) {
            e.Proxy = proxy; 
        }

        MyProxy proxy = new MyProxy();

        public class MyProxy : IWebProxy {
            ICredentials credentials;

            public ICredentials Credentials {
                get {
                    return credentials;
                }
                set {
                    credentials = value;
                }
            }

            public Uri GetProxy(Uri destination) {
                return destination;
            }

            public bool IsBypassed(Uri host) {
                return true;
            }
        }

    }
}

See Also

MapWebRequestEventArgs Class

MapWebRequestEventArgs Members

DevExpress.Xpf.Map Namespace