How do I loop through all the features in a FeatureLayer and get/set their attributes in v4 ?
Marc,
You can get the graphics from the layers view:
// Carbon storage of trees in Warren Wilson College. var featureLayer = new FeatureLayer({ url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0" }); featureLayer.on("layer-view-create", function(evt){ //The LayerView for the layer that emitted this event console.info(evt.layerView); });
The layerView has a graphics property.
But be aware of this note in the docs:
In this version of the API, geometries and attributes of features in a FeatureLayer cannot be added, deleted, or edited.
var layerView = view.getLayerView(layer);if (typeof layerView !== "undefined") {
layerView.graphics.forEach(function(graphic) {
//code here
});
}
The Docs are still incomplete and in Beta as well.
Thanks. That worked. I didn't see graphics as a property of LayerView in the beta 3 API reference
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.