Click or drag to resize
Code Example - GeoRSSLayerWindow

Creates a GeoRssLayer based on the United States Geological Survey earthquake feed and assigned a SimpleRenderer.

Code Example
GeoRSSLayer Window

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="GeoRSSLayerWindow.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"
        Tag="GeoRSSLayerWindow" >

    <Grid>
        <Grid.Resources>

            <!-- Create a custom SimpleMarkerSymbol earthquake locations. -->
            <esri:SimpleRenderer x:Key="MySimpleRenderer">
                <esri:SimpleMarkerSymbol Color="#FF0A57FC" Size="12" Style="Triangle" />
            </esri:SimpleRenderer>

        </Grid.Resources>

        <!-- Add a MapView Control. Set the WrapAround mode to True so that map can pan around continuously. -->
        <esri:MapView x:Name="MapView1" WrapAround="True">

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

                <!-- Add a backdrop ArcGISTiledMapServiceLayer. -->
                <esri:ArcGISTiledMapServiceLayer 
                    ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />

                <!-- Add a GeoRssLayer. A custom SimpleRenderer is applied based on the settings in the XAML file 
                in the Grid.Resources section. -->
                <esri:GeoRssLayer ID="MyGeoRssLayer" Renderer="{StaticResource MySimpleRenderer}"
                                  ServiceUri="http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.atom"  />
            </esri:Map>
        </esri:MapView>


        <StackPanel Width="300" HorizontalAlignment="Right" VerticalAlignment="Top" Background="Black"
                    Orientation="Vertical">

            <!-- Add a button for the user to manually refresh the GeoRssLayer data feed. -->
            <Button Margin="3" Content="Update" Click="OnLayerUpdateButtonClick"/>

            <!-- Textbox to display a message if the GeoRssLayer data feed refresh was successful. -->
            <TextBlock x:Name="OutputTextBox" Foreground="White"/>

        </StackPanel>
    </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 "GeoRSSLayerWindow.MainWindow" to be just "MainWindow".

// NOTE: Creates a GeoRssLayer based on the United States Geological Survey earthquake feed and assigned 
// a SimpleRenderer.

namespace GeoRSSLayerWindow
{
    public partial class MainWindow : System.Windows.Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Init();

        }

        private async void Init()
        {
            var layer = MapView1.Map.Layers["MyGeoRssLayer"];
            await layer.InitializeAsync();

        }

        private async void OnLayerUpdateButtonClick(object sender, System.Windows.RoutedEventArgs e)
        {

            try
            {
                // Clear out any existing messages to the user.
                OutputTextBox.Text = "";

                // Get the GeoRssLayer from the Map. The GeoRssLayer was previously added in the Xaml.
                Esri.ArcGISRuntime.Layers.GeoRssLayer myGeoRssLayer = null;
                myGeoRssLayer = MapView1.Map.Layers[1] as Esri.ArcGISRuntime.Layers.GeoRssLayer;

                // Ensure we have a something for the GeoRssLayer
                if (myGeoRssLayer != null)
                {

                    // Reload the information about the GeoRssLayer from the feed source.
                    await myGeoRssLayer.UpdateAsync();

                    // Display a message to the user that the GeoRssLayer was updated successfully.
                    OutputTextBox.Text = "The GeoRssLayer was updated successfully.";

                }


            }
            catch (System.Exception ex)
            {

                // There was some problem with the application. Provide details to the user. 
                System.Windows.MessageBox.Show(ex.Message);

            }

        }

    }
}