Skip to main content
All docs
V25.1
  • DevExpress v25.1 Update — Your Feedback Matters

    Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

    Take the survey Not interested

    GeoJsonFileDataAdapter Class

    A data adapter that loads data from GeoJSON files, and displays it on vector layers.

    Namespace: DevExpress.Xpf.Map

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

    NuGet Package: DevExpress.Wpf.Map

    #Declaration

    public class GeoJsonFileDataAdapter :
        MapGeoDataAdapter

    #Remarks

    The Map Control allows you to display data from GeoJSON files that store geographical objects in the JSON format.

    The following table lists supported GeoJSON elements and corresponding map items:

    GeoJSON element

    Map item

    Point

    MapDot

    MultiPoint

    A list of MapDot objects

    LineString

    MapPolyline

    MultiLineString

    MapPath

    Polygon, MultiPolygon

    MapPath

    GeometryCollection

    MapDot, MapPolyline, MapPath

    Follow the steps below to load data from a .GeoJSON file:

    1. Add a VectorLayer object to the MapControl.Layers collection.
    2. Create a GeoJsonFileDataAdapter object.
    3. Specify the path to a GeoJSON file via the MapGeoDataAdapter.FileUri property.
    4. Assign the GeoJsonFileDataAdapter to the VectorLayer.Data property.
    5. Optionally, you can customize generated items in the MapGeoDataAdapter.ShapesLoaded event handler.
    using DevExpress.Xpf.Map;
    using System.Windows;
    using System.Windows.Media;
    namespace FileDataAdapters {
        public partial class MainWindow : Window {
            public MainWindow() {
                InitializeComponent();
            }
            private void OnVectorLayerDataLoaded(object sender, DataLoadedEventArgs e) {
                mapControl.ZoomToFitLayerItems(new LayerBase[] { vectorLayer });
            }
            private void OnDataAdapterShapesLoaded(object sender, ShapesLoadedEventArgs e) {
                foreach (MapDot item in e.Shapes) {
                    item.Fill = Brushes.Red;
                    item.Size = 8;
                }
            }
        }
    }
    

    Note: In the example above, the GeoJson file’s Build Action is set to Resource.

    See Also