WinForms Map Control (coming in 13.1)

As we near release I thought I would show you another WinForms gem we are adding in 13.1: the WinForms Map Control. When it comes to data analysis the key to understanding is the concise display of many dimensions. A map allows you to convey locality in a truly unparalleled way. This sample represents the top 25 US airports (zoomed into the New York/New Jersey area):

WinForms Map Control

Adding a Map to your WinForms project is a simple drag and drop operation. Once the control is on your Form, you can add an Image Layer from either Bing or OpenStreet (the example above is OpenStreet). You can additionally add any number of vector layers from either a file (KML, SHP supported), from a database, or directly in code.

WinForms Map Control Layers

For this example I used our soon-to-be-released Spreadsheet API to load a csv file of airport locations directly into the map:

var layer = (VectorItemsLayer)mapControl1.Layers[1];

Workbook workbook = new Workbook();
workbook.LoadDocument("airports.csv");

Worksheet sheet = workbook.Worksheets.ActiveWorksheet;

for (int i = 1; i <= sheet.Rows.LastUsedIndex; i++)
{
    string code = sheet[i, 0].DisplayText;
    double lat = sheet[i, 1].Value.NumericValue;
    double lng = sheet[i, 2].Value.NumericValue;

    MapPushpin pushpin = new MapPushpin { Location = new GeoPoint(lat, lng), ToolTipPattern = code };
    layer.Items.Add(pushpin);
}

mapControl1.ZoomLevel = 4.5;
mapControl1.CenterPoint = new GeoPoint(37.50, -98.35);

The code simply loads the csv file and creates pusphins for each airport represented in the data. Since these are only US airports, I zoom in and center the map using the ZoomLevel and CenterPoint properties in the map. Aside from the pushpin, there are a number of other map elements that can be added including Dots, Rectangles, Polygons, Paths, and even a Custom Element:

WinForms Map Control Map Elements

We are tremendously excited for the great crop of things coming during our 13.1 series of releases.

As always, if there are any comments and/or questions, feel free to get a hold of me!

Seth Juarez
Email: sethj@devexpress.com
Twitter: @SethJuarez

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.