OpenLayers OpenLayers

Ticket #705: georsslayer_with_icons.patch

File georsslayer_with_icons.patch, 2.6 kB (added by penyaskito, 1 year ago)

A patch that adds a icon to the GeoRSS layer and a test for it.

  • lib/OpenLayers/Layer/GeoRSS.js

    old new  
    2323    /** @type OpenLayers.Feature */ 
    2424    selectedFeature: null, 
    2525 
     26    /**@type OpenLayers.Icon */ 
     27    icon:null, 
     28     
    2629    /** 
    2730    * @constructor 
    2831    * 
    2932    * @param {String} name 
    3033    * @param {String} location 
    3134    */ 
    32     initialize: function(name, location) { 
    33         OpenLayers.Layer.Markers.prototype.initialize.apply(this, [name]); 
     35    initialize: function(name, location, options) { 
     36        OpenLayers.Layer.Markers.prototype.initialize.apply(this, [name,options]); 
    3437        this.location = location; 
    3538        this.features = new Array(); 
    3639        OpenLayers.loadURL(location, null, this, this.parseData); 
     
    143146              catch (e) {} 
    144147            } 
    145148 
    146             data.icon = OpenLayers.Marker.defaultIcon(); 
     149            data.icon = this.icon == null ? OpenLayers.Marker.defaultIcon(): this.icon.clone(); 
    147150            data.popupSize = new OpenLayers.Size(250, 120); 
    148151            if ((title != null) && (description != null)) { 
    149152                contentHTML = '<div class="olLayerGeoRSSClose">[x]</div>';  
  • tests/Layer/test_GeoRSS.html

    old new  
    8282        }); 
    8383    } 
    8484 
     85    function test_04_Layer_GeoRSS_icon(t) { 
     86        t.plan( 3 ); 
     87        layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt); 
     88        var the_icon = new OpenLayers.Icon('http://boston.openguides.org/markers/AQUA.png'); 
     89        var otherLayer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt,{icon:the_icon}); 
     90        var map = new OpenLayers.Map('map'); 
     91        var baseLayer = new OpenLayers.Layer.WMS("Test Layer",  
     92            "http://octo.metacarta.com/cgi-bin/mapserv?", 
     93            {map: "/mapdata/vmap_wms.map", layers: "basic"}); 
     94        map.addLayer(baseLayer); 
     95        map.addLayers([layer,otherLayer]); 
     96        map.setCenter(new OpenLayers.LonLat(0,0),0); 
     97        var defaultIcon = OpenLayers.Marker.defaultIcon(); 
     98        t.delay_call( 1, function() { 
     99            t.ok(layer.markers[0].icon, "The layer has a icon"); 
     100            t.eq(layer.markers[0].icon.url, defaultIcon.url, "The layer without icon has the default icon."); 
     101            t.eq(otherLayer.markers[0].icon.url, the_icon.url,"The layer with an icon has that icon."); 
     102        }); 
     103    } 
     104     
    85105    function test_99_Layer_GeoRSS_destroy (t) { 
    86106        t.plan( 1 );     
    87107        layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);