October 21, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Building a Webpart to Display a Virtual Earth Map

  • July 26, 2007
  • By Mark Strawmyer
  • Send Email »
  • More Articles »
using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Xml;namespace MyColts.Net.Handler{   /// <summary>   /// Http Handler to provide access to geotargeting data.   /// </summary>   public class GeoData : IHttpHandler   {      /// <summary>Indicator if the handler can be      /// reused.</summary>      public bool IsReusable { get { return true; } }      /// <summary>      /// Constructor      /// </summary>      public GeoData()      {      }      /// <summary>      /// Process the request for the gallery image.      /// </summary>      /// <param name="context"></param>      public void ProcessRequest(HttpContext context)      {         // Send back a list of addresses for groups         System.Text.StringBuilder rssOutput =            new System.Text.StringBuilder(            "<channel><title>Group Addresses</title>");         try         {            using (TopGroupsTableAdapter gta =                   new TopGroupsTableAdapter())            {               using (TopGroupsDataTable dt =                  gta.GetAddressByTop50()               {                  double latitude = 0;                  double longitude = 0;                  foreach (TopGroupsRow groupRow in dt.Rows)                  {                     try                     {                        latitude = groupRow.fl_Latitude;                        longitude = groupRow.fl_Longitude;                     }                     catch                     {                        // Default to Indianapolis                        latitude = 39.76833;                        longitude = -86.15806;                     }                     // Add the group                     rssOutput.Append("<item>")                              .Append("<title>")                              .Append(groupRow.vc_Name)                              .Append("</title>")                              .Append("<description>")                              .Append("Category:")                              .Append(groupRow.vc_CategoryName)                              .Append(", Members: ")                              .Append(groupRow.in_MemberCnt)                              .Append(", New Members: ")                              .Append(groupRow.in_NewMemberCnt)                              .Append("</description>")                              .Append("<geo:lat>")                              .Append(latitude)                              .Append("</geo:lat>")                              .Append("<geo:long>")                              .Append(longitude)                              .Append("</geo:long>")                              .Append("</item>");                     }                  }               }               rssOutput.Append("</channel>");               XmlDocument document = new XmlDocument();               document.LoadXml("<rss version='2.0'                                 xmlns:geo='http://www.w3.org/2003/                                 01/geo/wgs84_pos#'></rss>");               XmlElement element = document.DocumentElement;               element.InnerXml = rssOutput.ToString();               context.Response.Write(document.DocumentElement.                                      OuterXml);            }            catch            {               System.Text.StringBuilder emptyOutput =                  new System.Text.StringBuilder                  ("<?xml version='1.0' ?>")                  .Append("<rss version='2.0'                          xmlns:geo='http://www.w3.org/2003/01/geo/                          wgs84_pos#'><channel>                          <title>Group Addresses</title>                          </channel></rss>");               context.Response.Write(emptyOutput.ToString());            }         }         context.Response.ContentType = "text/xml";      }   }}




Page 2 of 4



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel