Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

MapWebRequestEventArgs.Proxy Property

Gets or sets proxy information for the request.

Namespace: DevExpress.XtraMap

Assembly: DevExpress.XtraMap.v24.2.dll

NuGet Package: DevExpress.Win.Map

#Declaration

public IWebProxy Proxy { get; set; }

#Property Value

Type Description
IWebProxy

The IWebProxy that is used to proxy the request.

#Remarks

The following example shows how to use a WebProxy object to specify the request proxy settings. To pass the user Credentials with a web request, use a NetworkCredential object.

using System;
using System.Net;
using System.Windows.Forms;
using DevExpress.XtraMap;
// . . .
private void OnFormLoad(object sender, EventArgs e) {
    // Create a map.
    MapControl map = new MapControl();         
    map.Dock = DockStyle.Fill;
    map.ZoomLevel = 3;
    map.CenterPoint = new GeoPoint(40, -100);
    this.Controls.Add(map);
    ImageLayer layer = new ImageLayer();
    map.Layers.Add(layer);

    // Configure the map tile provider.
    BingMapDataProvider provider = new BingMapDataProvider();
    provider.BingKey = "Your Bing key here.";
    provider.WebRequest += OnProviderWebRequest;
    layer.DataProvider = provider;
}
private void OnProviderWebRequest(object sender, MapWebRequestEventArgs e) {
    e.Credentials = new NetworkCredential("userName", "password");
    e.Proxy = new WebProxy("http://proxyserver:80/", true);
}

Enable the UseDefaultCredentials property to use default credentials that the app.config file can contain in the defaultProxy element.

private void OnProviderWebRequest(object sender, MapWebRequestEventArgs e) {
    e.UseDefaultCredentials = true;
}

You can also implement a custom proxy. To do this, you should create a class that implements the IWebProxy interface. Then assign an object of this class to the Proxy property.

See Also