Skip to main content

ShapefileDataAdapter Class

A data adapter that loads data from shapefiles and displays it on vector layers.

Namespace: DevExpress.Xpf.Map

Assembly: DevExpress.Xpf.Map.v23.1.dll

NuGet Package: DevExpress.Wpf.Map


public class ShapefileDataAdapter :


The shapefile format is a geospatial vector data format that uses geometries (points, polylines, and polygons) to display geographic data (rivers, lakes, countries and others). The Map Control uses data from two types of files:

  • The .shp file that contains data about geometries.
  • The .dbf file that contains data associated with geometries (for example, names and GDP values for countries).

The Map Control stores data from the .dbf file to attributes for each vector item. You can colorize shapes based on attribute values or display this data in shape tooltips.

The image below shows a vector map loaded from a shapefile.

Map Control with data from a shape file

The following table lists supported shapefile elements and related map items:

Shape File Element

Map Item

PointM (the M value is ignored),
PointZ (the Z value is ignored),
MultipointM (the M value is ignored),
MultipointZ (the Z value is ignored).


PolylineM (the M value is ignored),
PolylineZ (the Z value is ignored).


PolygonM (the M value is ignored),
PolygonZ (the Z value is ignored).


For more information about shapefile element types, refer to ERSI Shapefile Technical Description.

Load Data

Follow the steps below to load data from a shapefile:

      <dxm:ShapefileDataAdapter FileUri="Data/Countries.shp"/>

View Example


If the Map Control does not display a shapefile, make sure that the ShapefileDataAdapter coordinate system is specified correctly. See the following help topic for more information: Provide Cartesian Data to a Geographical Map.

Access and Customize Map Items

When vector items are loaded, the MapGeoDataAdapter.ShapesLoaded event occurs. Use the e.Shapes property to access loaded shapes.

    <dxm:ShapefileDataAdapter FileUri="Data/Countries.shp"
private void ShapefileDataAdapter_ShapesLoaded(object sender, DevExpress.Xpf.Map.ShapesLoadedEventArgs e) {
  foreach (MapPath item in e.Shapes) {
      item.Fill = Brushes.Gray;

Use the MapControl.ZoomToFitLayerItems method to zoom a map to fit layer items.

<dxm:MapControl x:Name="mapControl">
 <dxm:VectorLayer DataLoaded="VectorLayer_DataLoaded">
   <dxm:ShapefileDataAdapter FileUri="Data/countries.shp" />
 private void VectorLayer_DataLoaded(object sender, DataLoadedEventArgs e) {
  mapControl.ZoomToFitLayerItems(new LayerBase[] { mapLayer });

You can change shape colors based on shape data. Refer to the following help topic for more information: Colorizers.

You can also group items of the same type. To do this, initialize the MapDataAdapterBase.Clusterer property with a clusterer.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ShapefileDataAdapter class.


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.

See Also