0

I have created a web map in ArcGIS Online. Using the ArcGIS Maps SDK for JavaScript I can create a view of this map using JavaScript and HTML.

The webmap works and I can view all data layers within this map.

I would like to feed in additional data using a GeoRSS Feed. I can add the feed directly into the webmap or I can load the data after the webmap is loaded using the "esri/layers/GeoRSSLayer" Constructor. I have used both methodologies and it works as expected.

I have been using the documentation from the ESRI Developer Site.

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoRSSLayer.html

I can view the data from the GeoRSS Feed, as well as interact with the GeoRSS data when clicking on the data in the map view.

I have seen in previous versions of the SDK that it is possible to access the attributes of the GeoRSS using the "items" Property. This returns an array of the features within a GeoRSS.

https://developers.arcgis.com/javascript/3/jsapi/georsslayer-amd.html

 var georssLayer = new GeoRSSLayer( ... );
  array.forEach(georssLayer.items,function(item){
    var attributes = item.attributes;
  });

Is there a way to access the features / attributes of a GeoRSS using the latest SDK (June 2023 - v4.27)?

1 Answer 1

1

Little inspection of RSS layer in browser debugger showed you can get layer features with the following code:

const layer = new GeoRSSLayer({
  url: "https://arcgis.github.io/arcgis-samples-javascript/sample-data/layers-georss/sample-georss.xml"
});
layer.on("layerview-create", function(event){
  layer.featureCollections.forEach(function(collection) {
    console.log('collection: ', collection);
    collection.featureSet.features.forEach(function(feature) {
      console.log('feature: ', feature);
    });
  });
});

EDIT

const layer = new GeoRSSLayer({
  url: "https://arcgis.github.io/arcgis-samples-javascript/sample-data/layers-georss/sample-georss.xml"
});
//added the line below to get it to work in my example
webmap.add(layer);
//
layer.on("layerview-create", function(event){
  layer.featureCollections.forEach(function(collection) {
    console.log('collection: ', collection);
    collection.featureSet.features.forEach(function(feature) {
      console.log('feature: ', feature);
    });
  });
});
1
  • Once again thank you @TomazicM. This got me to where I needed to be. I had to make one change. After the layer is created - const layer = new ... I added in a line: webmap.add(layer) and that got me exactly what I needed from the GeoRSS. Commented Jul 18, 2023 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.