DevExpress v24.2 Update — Your Feedback Matters
Our What's New in v24.2 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.v24.2.dll
NuGet Package :
DevExpress.Wpf.Map
# Declaration
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 :
Follow the steps below to load data from a .GeoJSON file:
Add a VectorLayer object to the MapControl.Layers collection.
Create a GeoJsonFileDataAdapter object.
Specify the path to a GeoJSON file via the MapGeoDataAdapter.FileUri property.
Assign the GeoJsonFileDataAdapter to the VectorLayer.Data property.
Optionally, you can customize generated items in the MapGeoDataAdapter.ShapesLoaded event handler.
<Window xmlns:dxm ="http://schemas.devexpress.com/winfx/2008/xaml/map"
xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d ="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc ="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local ="clr-namespace:FileDataAdapters"
x:Class ="FileDataAdapters.MainWindow"
xmlns:sys ="clr-namespace:System;assembly=System"
mc:Ignorable ="d"
Title ="MainWindow" Height ="450" Width ="800" >
<Grid >
<dxm:MapControl x:Name ="mapControl" >
<dxm:ImageLayer >
<dxm:BingMapDataProvider Kind ="Road"
BingKey ="Your-BingKey-here" />
</dxm:ImageLayer >
<dxm:VectorLayer x:Name ="vectorLayer" DataLoaded ="OnVectorLayerDataLoaded" >
<dxm:VectorLayer.Data >
<dxm:GeoJsonFileDataAdapter ShapesLoaded ="OnDataAdapterShapesLoaded" >
<dxm:GeoJsonFileDataAdapter.FileUri >
<sys:Uri > pack://application:,,,/FileDataAdapters;component/Data/subway-entrances.geojson</sys:Uri >
</dxm:GeoJsonFileDataAdapter.FileUri >
</dxm:GeoJsonFileDataAdapter >
</dxm:VectorLayer.Data >
</dxm:VectorLayer >
</dxm:MapControl >
</Grid >
</Window >
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 ;
}
}
}
}
Imports DevExpress.Xpf.Map
Imports System.Windows
Imports System.Windows.Media
Namespace FileDataAdapters
Public Partial Class MainWindow
Inherits Window
Public Sub New ()
InitializeComponent()
End Sub
Private Sub OnVectorLayerDataLoaded(ByVal sender As Object , ByVal e As DataLoadedEventArgs)
mapControl.ZoomToFitLayerItems(New LayerBase() {vectorLayer})
End Sub
Private Sub OnDataAdapterShapesLoaded(ByVal sender As Object , ByVal e As ShapesLoadedEventArgs)
For Each item As MapDot In e.Shapes
item.Fill = Brushes.Red
item.Size = 8
Next
End Sub
End Class
End Namespace
Note : In the example above, the GeoJson file’s Build Action is set to Resource .
See Also