Accessing Remote GeoRSS from VE
Author: Mike McDougall
The Virtual Earth API requires that all GeoRSS xml be local when loading layers. To get around this limitation and load GeoRSS layers from external domains you can use a web handler that acts as a proxy and retrieves the external xml. To try this out create a generic handler named GeoRSSProxy.ashx and insert the following code:
using System;
using System.Web;
using System.IO;
using System.Text;
using System.Net;
publicclassGeoRSSProxy : IHttpHandler {
publicvoid ProcessRequest (HttpContext context) {
string source = context.Request.QueryString["source"];
context.Response.ContentType = "text/xml";
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(source);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader stream = newStreamReader(response.GetResponseStream(), Encoding.ASCII);
context.Response.Write(stream.ReadToEnd());
}
publicbool IsReusable {
get {
returnfalse;
}
}
}
Then in your aspx page add something similar to the following:
function AddLayer()
{
var proxyPath = '<%= Request.Url.ToString().Replace("Default.aspx", "Handler1.ashx") %>';
proxyPath += '?source=http://dev.live.com/virtualearth/sdk/georsstest.xml';
var layer = new VEShapeLayer();
var layerSpec = new VEShapeSourceSpecification(VEDataType.GeoRSS, proxyPath , l);
map.ImportShapeLayerData(veLayerSpec, onFeedLoad);
}