You are viewing help content for pre-release software. This document and the features it describes are subject to change. Switch to the current version.

ShapefileDataAdapter Class

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

Namespace: DevExpress.Xpf.Map

Assembly: DevExpress.Xpf.Map.v21.2.dll


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.

See Also