Click or drag to resize
Code Example - CSVLayerXaml

Demonstrates defining a CsvLayer in XAML and setting the serviceUri property to a text file hosted online by the United States Geological Survey (USGS).

Code Example
CSVLayer Xaml

This section contains selected code files from a Visual Studio project that emphasize specific ArcGIS Runtime SDK (Windows Desktop) features. For example: some code examples may accomplish the bulk of the work as a configuration property in the .xaml file and hence only the .xaml file will be shown in detail below. In other code examples, the .xaml is used to define the configuration of graphical elements for the application but the application logic is performed in the code behind, hence you may see both the .xaml and .cs/.vb files shown in detail below.

XAML
<Window x:Class="CSVLayerXaml.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
        Height="600" Width="800">

    <Grid x:Name="LayoutRoot">

        <Grid.Resources>

            <!-- Create a set of custom SimpleMarkerSymbol objects to denote the magnitude of 
            the earthquake being represented. -->
            <esri:SimpleMarkerSymbol x:Key="mag2to3" Color="#FF0A57FC" Size="12" Style="X" />
            <esri:SimpleMarkerSymbol x:Key="mag3to4" Color="#FF1CA2A3" Size="14" Style="X"/>
            <esri:SimpleMarkerSymbol x:Key="mag4to5" Color="#FF60AD12" Size="16" Style="Diamond" />
            <esri:SimpleMarkerSymbol x:Key="mag5to6" Color="#FFFFFE0A" Size="18" Style="Diamond" />
            <esri:SimpleMarkerSymbol x:Key="mag6to7" Color="#FFFDA208" Size="20" Style="Triangle" />
            <esri:SimpleMarkerSymbol x:Key="mag7to8" Color="#FFFB5107" Size="22" Style="Triangle" />

            <!-- Create a ClassBreaksRenderer that will consume the custom SimpleMarkerSymbol objects
            just defined. The Field property is set that matches the field header in the dataset being 
            served by the web service. -->
            <esri:ClassBreaksRenderer x:Key="MyClassBreaksRenderer" Field="Magnitude" >
                <esri:ClassBreaksRenderer.Infos>
                    <esri:ClassBreakInfo Minimum="2" Maximum="3" Symbol="{StaticResource mag2to3}" />
                    <esri:ClassBreakInfo Minimum="3" Maximum="4" Symbol="{StaticResource mag3to4}" />
                    <esri:ClassBreakInfo Minimum="4" Maximum="5" Symbol="{StaticResource mag4to5}" />
                    <esri:ClassBreakInfo Minimum="5" Maximum="6" Symbol="{StaticResource mag5to6}" />
                    <esri:ClassBreakInfo Minimum="6" Maximum="7" Symbol="{StaticResource mag6to7}" />
                    <esri:ClassBreakInfo Minimum="7" Maximum="8" Symbol="{StaticResource mag7to8}" />
                </esri:ClassBreaksRenderer.Infos>
            </esri:ClassBreaksRenderer>
        </Grid.Resources>

        <!-- Add a MapView Control and turn on the ability to have the layers scroll within the control (i.e WrapAround=True). -->
        <esri:MapView x:Name="MapView1" WrapAround="True" >

            <!-- Add a Map. -->
            <esri:Map x:Name="MyMap">

                <!-- Add a backdrop ArcGISTiledMapServiceLayer. -->
                <esri:ArcGISTiledMapServiceLayer ID="WorldTopoMap" 
                    ServiceUri="http://services.arcgisonline.com/arcgis/rest/services/world_topo_map/MapServer" />

                <!-- Add a CSVLayer. The XFieldName and YFieldName are specified for the spatial location coordinate 
                field headers that match the dataset provided by the ServiceUri. A custom ClassBreaksRenderer is 
                applied based the settings earlier in the XAML file in the Grid.Resoruces section. -->
                <esri:CsvLayer XFieldName="Lon" YFieldName="Lat" Renderer="{StaticResource MyClassBreaksRenderer}"
                    ServiceUri="http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M2.5.txt" >
                </esri:CsvLayer>
            </esri:Map>
        </esri:MapView>

    </Grid>
</Window>

SPECIAL NOTE: The XAML displayed above comes from a C# project. If you are a VB.NET developer, you will need to modify the text for the x:Class namespace from "CSVLayerXaml.MainWindow" to be just "MainWindow".