Back to Devexpress

How to: Load Data from a Shapefile

windowsforms-17539-controls-and-libraries-map-control-examples-vector-data-providing-data-how-to-load-data-from-a-shapefile.md

latest1.4 KB
Original Source

How to: Load Data from a Shapefile

  • Nov 13, 2018

To load shape data from a shapefile do the following.

View Example

csharp
// Create data for the MapLayer.
    MapLayer.Data = CreateData();
private MapDataAdapterBase CreateData() {
    Uri baseUri = new Uri(System.Reflection.Assembly.GetEntryAssembly().Location);

    // Create an adapter to load data from shapefile.
    ShapefileDataAdapter adapter = new ShapefileDataAdapter() {
        FileUri = new Uri(baseUri, filename)
    };

    return adapter;
}
vb
' Create data for the MapLayer.
    MapLayer.Data = CreateData()
Private Function CreateData() As MapDataAdapterBase
    Dim baseUri As New Uri(System.Reflection.Assembly.GetEntryAssembly().Location)

    ' Create an adapter to load data from shapefile.
    Dim adapter As New ShapefileDataAdapter() With {.FileUri = New Uri(baseUri, filename)}

    Return adapter
End Function