Geeks With Blogs

Lance's TextBox

RSSBus is good for more than just generating RSS feeds or helping you easily create an API for your data or services. Its also useful in easily outputting other formats as well, such as KML (an XML format for Google Earth).

For example, recently Tim posted an example of using XmlTextWriter to generate KML. For most of ius, its not rocket science, but compare his code and the ease of writing it with how it can be done with RSSBus. With RSSBus you can just literally write the XML and plug-in the values you want to change with variables like [icon], etc.

Tim's example takes three querystring variables: lon (a longitude coordinate), lat (a latitude coordinate), and icon (an icon to mark the location in Google Earth). Below is the same example as an RSSBus template. Simply hit the template with your own lat, lon, and icon, and the KML is generated and opened on your machine. If you do not provide a lat, lon, and icon it will default to Bank of America Stadium where the Carolina Panthers win.

You can hit this script live here.

Also check out FeedMapper, which can also generate KML (as well as Virtual Earth and Yahoo maps) for entire feeds.

<rsb:allow user="*" host="*"/>

<!-- This script takes the following optional inputs from the querystring:
lat - latitude of geographic point
lon - longitude of geographic point
icon - url of icon that will plot the point

<!-- Set the content type for kml -->
<rsb:set item=_httpheaders attr="Content-Type" value="application/"/>

<!-- check for required inputs, or set defaults -->
<rsb:set attr="lat" value="[lat | def('35.2257')]" />
<rsb:set attr="lon" value="[lon | def('-80.8531')]" />
<rsb:set attr="icon" value="[icon | def('')]" />

<xml version="1.0" encoding="utf-8"?>
<kml xmlns="">
  <Snippet>KML generated by RSSBus</Snippet>
  <description>KML Demo</description>
  <name>KML Demo</name>
    <coordinates>[lon], [lat], 0</coordinates>

Technorati : , , ,

Posted on Monday, October 2, 2006 9:23 AM Programming , Software | Back to top

Comments on this post: Generating KML with RSSBus

# re: Generating KML with RSSBus
Requesting Gravatar...
My next post is going to be titled, "If you don't like how I'm doing this, wait 3 days and Lance will show you an easier way with RSSBus" :)

Nice touch carrying on the football stadium trend.

I've been looking to redo how I handle KML history in Where's Tim now that timestamps are supported, I should use RSSBus for that.
Left by Tim Hibbard on Oct 02, 2006 9:54 AM

Your comment:
 (will show your gravatar)

Copyright © Lance Robinson | Powered by: