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

MapControl Class

Displays raster and vector maps. Supports both popular map services (Bing Maps and OpenStreetMap) and custom map data servers inside your corporate network. See Map Control.

Namespace: DevExpress.XtraMap

Assembly: DevExpress.XtraMap.v18.2.dll

Declaration

[ComVisible(true)]
[ToolboxBitmap(typeof(MapControl), "Bitmaps256.MapControl.bmp")]
[Docking(DockingBehavior.Ask)]
public class MapControl :
    Control,
    IMapControl,
    ISupportChildsControl,
    ISupportLookAndFeel,
    ISupportInitialize,
    IToolTipControlClient,
    IGestureClient,
    IMouseWheelSupport,
    IMouseWheelScrollClient,
    IMapAnimatableItem,
    IPrintable,
    IBasePrintable,
    IServiceContainer,
    IServiceProvider,
    IMapControlEventsListener,
    IComponentChangeServiceProvider,
    IDesignTimeInteractionProvider,
    IDrawEventsProvider

The following members return MapControl objects:

Remarks

The DevExpress Map control provides all the functionality required to embed popular map services into your WinForms applications. You are free to choose from any existing map data resource (like Bing Maps or OpenStreetMap) or establish your own map data server inside your corporate network.

In addition to using raster map images, you can also utilize vector elements of any shape, stored either in Shapefiles or other formats. The control has built-in navigation elements, supports animated zooming, element highlighting and so much more.

The following image demonstrates a MapControl.

BingMap

To get acquainted with using the MapControl, please refer to the Getting Started section.

Example

This example describes how to programmatically add a MapControl in a Windows Forms application and connect this control to the OpenStreetMap data provider.

  • Run MS Visual Studio.
  • Create a new Windows Forms Application project or open an existing one.
  • Open the Solution Explorer, right-click References and choose Add Reference… to add the Map Control Library.

    Add Reference

  • In the Extensions tab, select the DevExpress.XtraMap, DevExpress.Map.Core, DevExpress.Data and DevExpress.Utils assemblies and click OK.

    Add Assemblies

  • Write the following (or similar) code:
using System;
using System.Windows.Forms;
using DevExpress.XtraMap;

namespace CreateMap {
    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;

            // Create a layer.
            ImageLayer layer = new ImageLayer();
            map.Layers.Add(layer);

            // Create a data provider.
            OpenStreetMapDataProvider provider = new OpenStreetMapDataProvider();
            layer.DataProvider = provider;

            // Specify the map zoom level and center point. 
            map.ZoomLevel = 2;
            map.CenterPoint = new GeoPoint(38, -100);

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