Geeks With Blogs

Lance's TextBox

I've mentioned before how you can generate Google Earth KML using RSSBus.

The current beta of RSSBus already comes with a yahooMaps operation that will generate an RSS feed that contains a Yahoo Map of a particular location. 

Virtual Earth, you say?  The LoadMap function of Virtual Earth takes a latitude and longitude coordinate as input, so here is some RSSBus Template code that will call the RSSBus yahooGeocode operation and use its lat/long output to generate a Virtual Earth map. 

The first step is to define some inputs.  State, Streetaddress, and City will all be required inputs of the map you'd like to generate.  Since their values are set as variables (defined in square brackets), they are taken from the querystring variable with the same name.  Zoom, Style, and Fixed will all be optional inputs with defaults assigned by the template (thats the def() that you see in the defined value.  If the variable is not defined in the querystring, it the value in the argument to def() will be used instead). 

Note:  Inputs can come from sources other than the URL querystring - such as regular encoded http post data, a web service, an RSS feed, or another RSSBus operation call.

<rsb:set item="input" attr="state" value="[state]" /> 
<rsb:set item="input" attr="streetaddress" value="[streetaddress]" /> 
<rsb:set item="input" attr="city" value="[city]" /> 
<rsb:set item="input" attr="zoom" value="[zoom | def('10')]" />
<rsb:set item="input" attr="style" value="[style | def('a')]" />
<rsb:set item="input" attr="fixed" value="[fixed | def('false')]" />

Next output the html page and necessary script tags to call the Virtual Earth javascript functions:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
<script src="">script> 
var map = null;
function GetMap() 
map = new VEMap('myMap');
<rsb:call op=yahooGeocode in="input" out="output">
map.LoadMap(new VELatLong([yahoo:latitude], [yahoo:longitude]), [input.zoom] ,'[]' ,[input.fixed]);
<body onload="GetMap();"> 
<div id='myMap' style="position:relative; width:400px; height:400px;">div> 

Above, notice that inside the GetMap() function definition, I am making an rsb:call to the yahooGeocode operation.  This is translating the address that was input to a latitude and longitude coordinate.  This coordinate ([yahoo:latitude], [yahoo:longitude]), along with the optional inputs we defined in the template (zoom, style, and fixed) gets passed to Virtual Earth's VELatLong() in order to define the map.

After I save this template in RSSBus, I can access it with the URL http://localhost:1110/VirtualEarth.rsb.htm?city=durham&state=nc&streetaddress=5007%20Southpark%20Dr

I can specify zoom, style, and fixed arguments in the querystring if I like:  http://localhost:1110/VirtualEarth.rsb.htm?city=durham&state=nc&streetaddress=5007%20Southpark%20Dr&style=h&zoom=16&fixed=true.


Posted on Wednesday, June 21, 2006 12:52 PM Programming , Software | Back to top

Comments on this post: RSSBus Template to output Virtual Earth Maps

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Lance Robinson | Powered by: