Skip to main content
A newer version of this page is available. .

OpenStreetMapDataProvider Class

The class that loads map images from a web resource that provides data in the OpenStreetMap format.

Namespace: DevExpress.XtraMap

Assembly: DevExpress.XtraMap.v18.2.dll

Declaration

public class OpenStreetMapDataProvider :
    MapDataProviderBase,
    IOpenStreetMapKindProvider

Remarks

Before using map images in the OpenStreetMap format, please review the Copyright and License and Tile usage policy pages. To control which web resource should be used in your application as an OpenStreetMap data provider, you should assign a specific value for the OpenStreetMapDataProvider.TileUriTemplate property.

Example

This example demonstrates how to connect to the OpenStreetMap using the OpenStreetMapDataProvider object.

using System;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraMap;

namespace ConnectToOpenStreet {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {
            // Create a map control.
            MapControl map = new MapControl();

            // Specify the map position on the form.           
            map.Dock = DockStyle.Fill;

            // Add the map control to the window.
            this.Controls.Add(map);

            // Create an image tiles layer and add it to the map.
            ImageLayer tileLayer = new ImageLayer();
            map.Layers.Add(tileLayer);            

            // Create an Open Street data provider.
            OpenStreetMapDataProvider provider = new OpenStreetMapDataProvider();
            tileLayer.DataProvider = provider;

            // Specify a template that is used to obtain image tiles. 
            provider.TileUriTemplate = "http://{subdomain}.tile.MyCustomOSMProvider.org/{tileLevel}/{tileX}/{tileY}.png";

            provider.WebRequest += OnWebRequest;
        }

        private void OnWebRequest(object sender, MapWebRequestEventArgs e) {
            e.UserAgent = "XtraMap Getting Started - Connect to OpenStreetMap";
        }
    }
}
See Also