Skip to content

Instantly share code, notes, and snippets.

@andrewn
Created October 8, 2009 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewn/204909 to your computer and use it in GitHub Desktop.
Save andrewn/204909 to your computer and use it in GitHub Desktop.
OpenLayers.Format.GeoRSS.prototype.createFeatureFromItem: function(item) {
var geometry = this.createGeometryFromItem(item);
/* Provide defaults for title and description */
var title = this.getChildValue(item, "*", "title", this.featureTitle);
/* First try RSS descriptions, then Atom summaries */
var description = this.getChildValue(
item, "*", "description",
this.getChildValue(item, "*", "content",
this.getChildValue(item, "*", "summary", this.featureDescription)));
/* If no link URL is found in the first child node, try the
href attribute */
var link = this.getChildValue(item, "*", "link");
if(!link) {
try {
link = this.getElementsByTagNameNS(item, "*", "link")[0].getAttribute("href");
} catch(e) {
link = null;
}
}
var id = this.getChildValue(item, "*", "id", null);
// Get the image url from the feed item
var url = this.getChildValue( item, "*", "image", null);
var data = {
"title": title,
"description": description,
"link": link,
"url": url // The url of the pinpoint image
};
var feature = new OpenLayers.Feature.Vector(geometry, data);
feature.fid = id;
return feature;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment