Friday, November 23, 2007

GeoRSS Support

AWX has GeoRSS support. So given for example the following feed (on my local machine I can access it as http://ccccmac/~mansour/geofeed.xml):

<?xml version="1.0"?>
<rss xmlns:georss="http://www.georss.org/georss" version="2.0">
 <channel>
  <title>GeoRSS-Simple Example</title>
  <description>Example GeoRSS-Simple Feed</description>
  <georss:box>38.373576,-122.854022,38.423121,-122.804327</georss:box>
  <item>
   <title>GeoRSS-Simple Polygon</title>
   <description>A polygon describes an arbitrary geographic shape. The 
  format is a series of ordered latitude, longitude pairs. The last pair 
  must be the same as the first pair, closing the polygon.</description>
   <guid>urn:uuid:d496f4e3-7fd8-4169-ac6208e36dffa7f0</guid>
   <link>http://georss.org/simple</link>
   <author>georss supporter</author>
   <pubDate>Mon, 09 Jul 2007 10:49:00 PDT</pubDate>
   <georss:polygon>
  45.256 -110.45 46.46 -109.48 43.84 -109.86 45.256 -110.45
  </georss:polygon>
  </item>
 </channel>
</rss>

You can create a GeoRSS layer as follows:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
 xmlns:mx="http://www.adobe.com/2006/mxml"
 xmlns:awx="http://www.arcwebservices.com/2007/awx"
 layout="absolute"
 xmlns:layers="com.esri.aws.awx.map.layers.*">
 <mx:Script>
  <![CDATA[
   import flash.net.navigateToURL;
   import mx.events.ChildExistenceChangedEvent;
   import com.esri.aws.awx.map.layers.overlays.OverlayObject;
   
   private function onChildAdd( event : ChildExistenceChangedEvent ) : void
   {
    var overlayObject : OverlayObject = event.relatedObject as OverlayObject;
    overlayObject.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false, 0.0, true);
   }
   
   private function onMouseDown( event : MouseEvent ) : void
   {
    var overlayObject : OverlayObject = event.target as OverlayObject;
    navigateToURL( new URLRequest( overlayObject.link), "_blank");
   }
   
   private function onFeedLoad() : void
   {
    map.extent = geoRSSLayer.extent.createBuffer(0.2);
   }
  ]]>
 </mx:Script>
 <awx:Framework/>
 <awx:Map id="map" createDefaultLayers="false">
  <layers:GeoRSSLayer
   id="geoRSSLayer"
   feedUrl="http://ccccmac/~mansour/geofeed.xml"   
   feedLoad="onFeedLoad()"
   childAdd="onChildAdd(event)"
   >
   <layers:polygonStyle>
    <awx:PolygonStyle color="0xFFFF00" outlineColor="0x000000" outlineThickness="2"/>    
   </layers:polygonStyle>
  </layers:GeoRSSLayer>  
 </awx:Map>
</mx:Application>

In this example, I'm setting the GeoRSSLayer feed URL, and I have the option to set the style of the polygon, in this case a yellow filling with a 2 pixel wide black outline. On each added overlay, I'm adding a mouse down event listener, such that when I click on the overlay, I navigate to the associated URL. When the feed is fully loaded, I'm setting the map extent to the layer extent plus a 2 percent buffer.


Remember, if you want to access a remote GeoRSS feed, make sure that it has a crossdomain.xml file or you can always use a proxy server.

1 comment:

cp1436 said...

Any tips on using a proxyserver?