<?xml version="1.0" encoding="utf-8"?> <access-policy> <cross-domain-access> <policy> <allow-from http-request-headers="*" > <domain uri="*"/> </allow-from> <grant-to> <resource path="/" include-subpaths="true"/> </grant-to> </policy> </cross-domain-access> </access-policy>
#region Parse GeoRSS with Linq
private void RSS(Stream s)
{
try
{
GraphicsLayer graphicsLayer = Map.Layers["GeoRSSFeed"] as GraphicsLayer;
graphicsLayer.ClearGraphics();
XDocument doc = XDocument.Load(s);
XNamespace geo = "http://www.w3.org/2003/01/geo/wgs84_pos#";
XNamespace dc = "http://purl.org/dc/elements/1.1/";
var rssGraphics = from rssgraphic in doc.Descendants("item")
select new RssGraphic
{
Geometry = new MapPoint(
Convert.ToDouble(rssgraphic.Element(geo + "long").Value, System.Globalization.CultureInfo.InvariantCulture),
Convert.ToDouble(rssgraphic.Element(geo + "lat").Value, System.Globalization.CultureInfo.InvariantCulture)),
Symbol = LayoutRoot.Resources["QuakePictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol,
RssAttributes = new Dictionary<string, object>() { { "Title", rssgraphic.Element("title").Value },
{ "Link", rssgraphic.Element("link").Value } }
};
foreach (RssGraphic rssGraphic in rssGraphics)
{
rssGraphic.Geometry = _mercator.FromGeographic(rssGraphic.Geometry);
foreach (KeyValuePair<string, object> rssAttribute in rssGraphic.RssAttributes)
{
rssGraphic.Attributes.Add(rssAttribute.Key, rssAttribute.Value);
}
graphicsLayer.Graphics.Add((Graphic)rssGraphic);
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
#endregion
using System;
using System.Net;
using System.Web;
namespace MySilverlightProject.Web
{
public class SimpleHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var bytes = (new WebClient()).DownloadData(new Uri(context.Request["url"]));
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
context.Response.BufferOutput = false;
context.Response.BinaryWrite(bytes);
}
public bool IsReusable { get { return false; } }
}
}
Instead of pointing to http://www.openstreetmap.org/traces/rss, you would reference http://myserver/mypath/myproxy.ashx?url=www.openstreetmap.org/traces/rss instead. using System;
using System.Collections.Specialized;
using System.Drawing;
using System.IO;
using System.Net;
using System.Text;
using System.Web;
namespace Viewer.Web
{
/// <summary>
/// Summary description for proxy
/// </summary>
public class proxy : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
{
var bytes = (new WebClient()).DownloadData(new Uri(context.Request["url"]));
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
context.Response.BufferOutput = false;
context.Response.BinaryWrite(bytes);
}
}
public bool IsReusable { get { return false; } }
}
} #region Load GeoRSS Feeds
private void LoadFeeds()
{
try
{
String uri = Configuration.getLocalAppSetting("homeURL");
String url = Configuration.getRSSAppSetting(param);
LoadRSS(uri + "proxy.ashx?url=" + url);
DispatcherTimer UpdateTimer = new DispatcherTimer();
UpdateTimer.Interval = new TimeSpan(0, 0, 0, 60, 0);
UpdateTimer.Tick += (evtsender, args) =>
{
LoadRSS(uri + "proxy.ashx?url=" + url);
};
UpdateTimer.Start();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
#endregion