Mobile Line Of Business

Richard Jones (MVP)

  Home  |   Contact  |   Syndication    |   Login
  200 Posts | 0 Stories | 36 Comments | 0 Trackbacks

News

Welcome to the Mobile Line Of Business Blog

Tag Cloud


Archives

Post Categories

Image Galleries

About

Carl and I (@Carl_Iversen on Twitter :-) ), needed a way of showing a route map from Dynamics NAV today.   So what we needed was a way to quickly show a map with a route and pushpins indicating each weigh point.

Virtual Earth, has this marvellous feature that lets you show a GeoRss feed overlaid on a map, complete with polygons, pushpins and lines.   Building a GeoRss feed file is a snap and this is how we did it with the following bit of C# in an ASP.Net page.  The Virtual Earth SDK is a great place to start,  http://dev.live.com/Virtualearth/sdk/     It pretty much is a copy and paste job to get going with some fairly amazing looking maps.

 

We loop around a class containing our individual points in our case and array of Trip_operation class in a collection called ouroperations.

This is from the page load method,  I’m sure you can see what we’ve been up to :-)

 

    MemoryStream stream = new MemoryStream();
       XmlTextWriter xmlw = new XmlTextWriter(stream, System.Text.Encoding.UTF8);
 
                xmlw.WriteStartDocument();
                xmlw.WriteStartElement("rss");
                xmlw.WriteAttributeString("version", "2.0");       
                xmlw.WriteAttributeString("xmlns:geo", "http://www.w3.org/2003/01/geo/wgs84_pos#");
                xmlw.WriteAttributeString("xmlns:georss", "http://www.georss.org/georss");
                xmlw.WriteAttributeString("xmlns:gml", "http://www.opengis.net/gml");
                xmlw.WriteAttributeString("xmlns:mappoint", "http://virtualearth.msn.com/apis/annotate#");       
 
                xmlw.WriteStartElement("channel");
                xmlw.WriteElementString("title", "OUR TITLE");
                xmlw.WriteElementString("link", "");
                xmlw.WriteElementString("description", "OUR DESCRIPTION"");
                xmlw.WriteElementString("mappointIntlCode","cht");
                StringBuilder sb = new StringBuilder();
                foreach (Trip_operation t in ouroperations)
                {
                    xmlw.WriteStartElement("item");
                    xmlw.WriteElementString("title", "OUR TITLE");
                    xmlw.WriteElementString("description", "OUR PIN DESCRIPTION);
                    xmlw.WriteElementString("geo:lat", t.Latitude.ToString());
                    xmlw.WriteElementString("geo:long", t.Longitude.ToString());
                    xmlw.WriteEndElement();
                }
 
                xmlw.WriteEndElement();
 
 
                xmlw.WriteEndElement();
 
                xmlw.WriteEndDocument();
                xmlw.Flush();
                topa.Dispose();
                 
        
        stream.Position = 0;
 
        StreamReader reader = new StreamReader(stream);
        byte[] bytes = System.Text.Encoding.UTF8.GetBytes(reader.ReadToEnd());
        Response.ContentType="text/xml";
                Response.BinaryWrite(bytes);
        Response.End();

 

Technorati Tags: ,
posted on Friday, January 30, 2009 7:55 PM