[OpenLayers-Users] Problems subclassing OpenLayers.Format.GeoRSS
Nick Whitelegg
Nick.Whitelegg at solent.ac.uk
Sat Aug 14 14:32:22 EDT 2010
Hello,
I'm trying to subclass OpenLayers.Format.GeoRSS; this is because I want to extract additional information from a GeoRSS feed that is not parsed with OpenLayers.Format.GeoRSS, such as geo:dir.
I've started a test subclass, doesn't do anything yet, for testing purposes only:
OpenLayers.Format.GeoRSSExt = OpenLayers.Class (OpenLayers.Format.GeoRSS,
{
initialize: function(options)
{
OpenLayers.Format.GeoRSS.prototype.initialize.apply
(this,arguments);
},
createFeatureFromItem: function (item)
{
OpenLayers.Format.GeoRSS.prototype.createFeatureFromItem.apply
(this,arguments);
alert('Title='+
this.getChildValue(item,"*","title","notitle"));
},
CLASS_NAME: "OpenLayers.Format.GeoRSSExt"
}
);
As can be seen, for the moment the overridden createFeatureFromItem() simply displays an alert box with the feature title. This works correctly - the title is displayed - but the items are not added to the vector layer (code as below, the code below works correctly when I just use a straight OpenLayers.Format.GeoRSS()):
georss = new OpenLayers.Layer.Vector
("OTV Panoramas",
{ strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.HTTP
({ url: "/otv/rss.php",
format: new OpenLayers.Format.GeoRSSExt() }),
'styleMap' : sm,
'projection': wgs84
} );
The specific error I get is "features[i] not defined" in line 1698 of the current release version (2.9) of OpenLayers.js.
Any ideas what I'm doing wrong here? As far as I can ascertain I am using the correct current way to subclass.
Thanks,
Nick
More information about the Users
mailing list