This sample demonstrates displaying an
ESRI.ArcGIS.Client.ToolkitDataSources GeoRSS feed draped over an
ArcGISTiledMapServiceLayer. The GeoRSS feed is provided by the
United States Geological Survey (USGS) and shows the point
locations of major earthquakes (Magnitude 5+) over the last 7 days.
A StaticResouce is defined to specify the symbology of the points
using a ESRI.ArcGIS.Client SimpleRenderer.
Download Sample Application
< UserControl x:Class = " ArcGISWPFSDK.GeoRssSimple "
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/client/2009 " >
< Grid x:Name = " LayoutRoot " >
< Grid.Resources >
< esri : SimpleRenderer x:Key = " MySimpleRenderer " >
< esri : SimpleRenderer.Symbol >
< esri : PictureMarkerSymbol Source = " /Assets/Images/quake-30x30.png " OffsetX = " 8 " OffsetY = " 8 " Width = " 16 " />
</ esri : SimpleRenderer.Symbol >
</ esri : SimpleRenderer >
</ Grid.Resources >
< esri : Map x:Name = " MyMap " WrapAround = " True " >
< esri : ArcGISTiledMapServiceLayer Url = " http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer " />
< esri : GeoRssLayer ID = " MyGeoRssLayer " Source = " http://earthquake.usgs.gov/earthquakes/catalogs/7day-M5.xml "
Visible = " False "
Renderer = " {StaticResource MySimpleRenderer} " >
< esri : GraphicsLayer.MapTip >
< Grid Background = " LightYellow " >
< StackPanel Orientation = " Horizontal " Margin = " 5 " >
< TextBlock Foreground = " Black " >
< Run Text = " {Binding [Title]} " />
< LineBreak />
< Run > Elevation: </ Run >
< Run Text = " {Binding [elev]} " />
</ TextBlock >
</ StackPanel >
< Border BorderBrush = " Black " BorderThickness = " 1 " />
</ Grid >
</ esri : GraphicsLayer.MapTip >
</ esri : GeoRssLayer >
</ esri : Map >
</ Grid >
</ UserControl >
using System;
using System.Collections.Generic;
using System.Windows.Controls;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;
using ESRI.ArcGIS.Client.Tasks;
using ESRI.ArcGIS.Client.Toolkit.DataSources;
namespace ArcGISWPFSDK
{
public partial class GeoRssSimple : UserControl
{
GeoRssLayer _geoRssLayer;
public GeoRssSimple()
{
InitializeComponent();
_geoRssLayer = MyMap.Layers["MyGeoRssLayer" ] as GeoRssLayer;
MyMap.Layers.LayersInitialized += Layers_LayersInitialized;
}
void Layers_LayersInitialized(object sender, EventArgs args)
{
MyMap.Layers.LayersInitialized -= Layers_LayersInitialized;
if (_geoRssLayer.Graphics.Count > 0)
updateGeoRssGraphics();
else // if GeoRss feed has not been returned yet, wait until Graphics property is set
_geoRssLayer.PropertyChanged += _geoRssLayer_PropertyChanged;
}
void _geoRssLayer_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "Graphics" )
{
_geoRssLayer.PropertyChanged -= _geoRssLayer_PropertyChanged;
updateGeoRssGraphics();
}
}
void updateGeoRssGraphics()
{
GeometryService geometryService =
new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer" );
// GeoRss-Simple feed always provides geometry in geographic (wgs84)
if (MyMap.SpatialReference != new SpatialReference(4326))
{
// make graphics layer visible when project completed
geometryService.ProjectCompleted += (evt, a) =>
{
for (int i = 0; i < a.Results.Count; i++)
_geoRssLayer.Graphics[i].Geometry = a.Results[i].Geometry;
_geoRssLayer.Visible = true ;
};
geometryService.ProjectAsync(_geoRssLayer.Graphics, MyMap.SpatialReference);
}
else if (MyMap.SpatialReference != null )
_geoRssLayer.Visible = true ;
}
}
}
Imports System.Collections.Generic
Imports System.Windows.Controls
Imports ESRI.ArcGIS.Client
Imports ESRI.ArcGIS.Client.Geometry
Imports ESRI.ArcGIS.Client.Tasks
Imports ESRI.ArcGIS.Client.Toolkit.DataSources
Namespace ArcGISWPFSDK
Partial Public Class GeoRssSimple
Inherits UserControl
Private _geoRssLayer As GeoRssLayer
Public Sub New ()
InitializeComponent()
_geoRssLayer = TryCast(MyMap.Layers("MyGeoRssLayer" ), GeoRssLayer)
AddHandler MyMap.Layers.LayersInitialized, AddressOf Layers_LayersInitialized
End Sub
Private Sub Layers_LayersInitialized(sender As Object , args As EventArgs)
RemoveHandler MyMap.Layers.LayersInitialized, AddressOf Layers_LayersInitialized
If _geoRssLayer.Graphics.Count > 0 Then
updateGeoRssGraphics()
Else
' if GeoRss feed has not been returned yet, wait until Graphics property is set
AddHandler _geoRssLayer.PropertyChanged, AddressOf _geoRssLayer_PropertyChanged
End If
End Sub
Private Sub _geoRssLayer_PropertyChanged(sender As Object , e As System.ComponentModel.PropertyChangedEventArgs)
If e.PropertyName = "Graphics" Then
RemoveHandler _geoRssLayer.PropertyChanged, AddressOf _geoRssLayer_PropertyChanged
updateGeoRssGraphics()
End If
End Sub
Private Sub updateGeoRssGraphics()
Dim geometryService As New GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer" )
' GeoRss-Simple feed always provides geometry in geographic (wgs84)
If MyMap.SpatialReference IsNot New SpatialReference(4326) Then
' make graphics layer visible when project completed
AddHandler geometryService.ProjectCompleted, Function (evt, a)
For i As Integer = 0 To a.Results.Count - 1
_geoRssLayer.Graphics(i).Geometry = a.Results(i).Geometry
Next
_geoRssLayer.Visible = True
End Function
geometryService.ProjectAsync(_geoRssLayer.Graphics, MyMap.SpatialReference)
ElseIf MyMap.SpatialReference IsNot Nothing Then
_geoRssLayer.Visible = True
End If
End Sub
End Class
End Namespace
5/16/2014