How to: Automatically Load Cartesian Data to a Geo Map

  • 3 minutes to read

To automatically load Cartesian map data from a shapefile onto a Geo map, do the following.

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map"
        xmlns:local="clr-namespace:LoadPrjData"
        xmlns:sys="clr-namespace:System;assembly=System"
        x:Class="LoadPrjData.MainWindow"
        Title="MainWindow" MinHeight="350" MinWidth="525" Loaded="Window_Loaded">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>


        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Label Grid.Column="0"  Margin="4,4,2,4" Content="Coordinate System:"/>
            <ComboBox Grid.Column="1" Name="cbCoordinateSystem" HorizontalAlignment="Stretch"
                      Margin="2,4,4,4" SelectedIndex="0" ItemsSource="{Binding Data}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Name}" Padding="4"/>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
            <Button Grid.Column="2" Content="Locate Vector Data" Margin="4" Padding="4" Click="Button_Click"></Button>
        </Grid>
        <dxm:MapControl Name="map"  Grid.Row="1">
            <dxm:ImageTilesLayer>
                <dxm:BingMapDataProvider Kind="Road" BingKey="YOUR BING KEY"/>
            </dxm:ImageTilesLayer>
            <dxm:VectorLayer ShapeFill="#60FF8800">
                <dxm:ShapefileDataAdapter 
                    FileUri="{Binding ElementName=cbCoordinateSystem, Path=SelectedValue.FileUri}"
                    SourceCoordinateSystem="{Binding ElementName=cbCoordinateSystem, Path=SelectedValue.CoordinateSystem}">
                </dxm:ShapefileDataAdapter>
            </dxm:VectorLayer>
        </dxm:MapControl>

    </Grid>
</Window>