OpenLayers OpenLayers

Ticket #1064: GeoRSS.patch

File GeoRSS.patch, 2.4 kB (added by thijsbrentjens, 1 year ago)

Patch, refresh GeoRSS layer

  • GeoRSS.js

    old new  
    1 /* Copyright (c) 2006-2007 MetaCarta, Inc., published under a modified BSD license. 
    2  * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt  
     1/* Copyright (c) 2006-2007 MetaCarta, Inc., published under the BSD license. 
     2 * See http://svn.openlayers.org/trunk/openlayers/release-license.txt  
    33 * for the full text of the license. */ 
    44 
    55 
     
    149149                        "title")[0].firstChild.nodeValue; 
    150150            } 
    151151            catch (e) { title="Untitled"; } 
    152             
     152             
     153            /* CUSTOM: add as a property of the feature */ 
     154            data.title = title; 
     155             
    153156            /* First try RSS descriptions, then Atom summaries */ 
    154157            var descr_nodes = null; 
    155158            try { 
     
    175178            } 
    176179            catch (e) { description="No description."; } 
    177180 
     181            /* CUSTOM: add as a property of the feature */ 
     182            data.description = description;          
     183             
    178184            /* If no link URL is found in the first child node, try the 
    179185               href attribute */ 
    180186            try { 
     
    187193              catch (e) {} 
    188194            } 
    189195 
     196            /* CUSTOM: add as a property of the feature */ 
     197            data.link = link;        
     198             
    190199            data.icon = this.icon == null ?  
    191200                                     OpenLayers.Marker.defaultIcon() :  
    192201                                     this.icon.clone(); 
     
    253262        }         
    254263    }, 
    255264     
     265    /** 
     266    * Method:  refresh 
     267    * Refreshes the GeoRSS layer. All old features will be removed, the feed's data is parsed again. 
     268    * Location of the feed gets an additional parameter called "currenttime" holding the currenttime in milliseconds to make sure the feed is not retrieved from the browser's cache.  
     269    * CUSTOM 
     270    * Thijs, 04-10-2007 
     271    */   
     272    refresh: function() { 
     273        var currentTime = new Date(); 
     274        var url = this.location; 
     275        var uniquePrefix = "?currenttime="; 
     276        if (url.indexOf(uniquePrefix) > 0) 
     277        { 
     278            url = url.substring(0,url.indexOf(uniquePrefix)); 
     279        } 
     280        this.location =  url + uniquePrefix + currentTime.getTime(); 
     281        this.clearFeatures(); // or move clearFeatures to parseData? To make sure that ONLY the items from the last feed are shown? 
     282        this.initialize(this.name, this.location, this.options); 
     283    }, 
     284     
    256285    /** @final @type String */ 
    257286    CLASS_NAME: "OpenLayers.Layer.GeoRSS" 
    258287});