| 49 | | // Create a layer with a style map. Giving the style map keys |
|---|
| 50 | | // for "default" and "select" rendering intent. |
|---|
| 51 | | markerLayer = new OpenLayers.Layer.Vector("", { |
|---|
| | 49 | // Create a GML layer with GeoRSS format and a style map. |
|---|
| | 50 | markerLayer = new OpenLayers.Layer.GML("Some images from Flickr", |
|---|
| | 51 | "xml/georss-flickr.xml", { |
|---|
| | 52 | format: OpenLayers.Format.GeoRSS, |
|---|
| | 53 | formatOptions: { |
|---|
| | 54 | // adds the thumbnail attribute to the feature |
|---|
| | 55 | createFeatureFromItem: function(item) { |
|---|
| | 56 | var feature = OpenLayers.Format.GeoRSS.prototype |
|---|
| | 57 | .createFeatureFromItem.apply(this, arguments); |
|---|
| | 58 | feature.attributes.thumbnail = |
|---|
| | 59 | this.getElementsByTagNameNS( |
|---|
| | 60 | item, "*", "thumbnail")[0].getAttribute("url"); |
|---|
| | 61 | return feature; |
|---|
| | 62 | } |
|---|
| | 63 | }, |
|---|
| | 64 | // Giving the style map keys for "default" and "select" |
|---|
| | 65 | // rendering intent, to make the image larger when selected |
|---|
| 78 | | |
|---|
| 79 | | OpenLayers.loadURL("xml/georss-flickr.xml", null, window, afterload); |
|---|
| 80 | | |
|---|
| 81 | | } |
|---|
| 82 | | |
|---|
| 83 | | function afterload(req) { |
|---|
| 84 | | // extended version of OpenLayers.Format.GeoRSS.createFeatureFromItem; |
|---|
| 85 | | // adds the thumbnail attribute to the feature |
|---|
| 86 | | function createFeatureFromItem(item) { |
|---|
| 87 | | var feature = OpenLayers.Format.GeoRSS.prototype |
|---|
| 88 | | .createFeatureFromItem.apply(this, arguments); |
|---|
| 89 | | feature.attributes.thumbnail = |
|---|
| 90 | | this.getElementsByTagNameNS( |
|---|
| 91 | | item, "*", "thumbnail")[0].getAttribute("url"); |
|---|
| 92 | | return feature; |
|---|
| 93 | | } |
|---|
| 94 | | |
|---|
| 95 | | var store = new OpenLayers.Format.GeoRSS({ |
|---|
| 96 | | createFeatureFromItem: createFeatureFromItem}); |
|---|
| 97 | | |
|---|
| 98 | | rss = store.read(req.responseText); |
|---|
| 99 | | |
|---|
| 100 | | markerLayer.setName("Some images from Flickr"); |
|---|
| 101 | | markerLayer.addFeatures(rss); |
|---|