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.1.dll
Declaration
[ToolboxTabName("DX.18.1: Data & Analytics")]
[Docking(DockingBehavior.Ask)]
[ComVisible(true)]
[ToolboxBitmap(typeof(MapControl), "Bitmaps256.MapControl.bmp")]
public class MapControl :
Control,
IMapControl,
ISupportChildsControl,
ISupportLookAndFeel,
ISupportInitialize,
IToolTipControlClient,
IGestureClient,
IMouseWheelSupport,
IMouseWheelScrollClient,
IMapAnimatableItem,
IPrintable,
IBasePrintable,
IServiceContainer,
IServiceProvider,
IMapControlEventsListener,
IComponentChangeServiceProvider,
IDesignTimeInteractionProvider,
IDrawEventsProvider
Related API Members
The following members accept/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.
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.
In the Extensions tab, select the DevExpress.XtraMap, DevExpress.Map.Core, DevExpress.Data and DevExpress.Utils assemblies and click OK.
- 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);
}
}
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the MapControl class.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.