I am trying to create a polygon feature layer from a feature collection using the ArcGIS API for Javascript. I have modified Esri's Flickr sample to use polygon geometries, rather than point geometries. The features are not getting added to the layer properly. I have put together a JSFiddle here that illustrates the problem. I have commented out the method where I add the features (line 137).
http://jsfiddle.net/gregKnight66/mmhqqan6/
There isn't an error per se, I am just not getting results (the features are not added to the layer).
var featureLayer = new FeatureLayer(featureCollection, {
id: 'buildingFeatures'
});
map.on("layers-add-result", function (results) {
addBuildingFeatures();
});
map.addLayers([featureLayer]);
function addBuildingFeatures() {
var features = buildingFeatures;
featureLayer.applyEdits(features, null, null);
}
Best Answer
I see two issues in your jsfiddle example:
addBuildingFeatures
is not actually being called. Add lineaddBuildingFeatures();
right below the function definition to call it.applyEdits
and passing yourbuildingFeatures
array of object(s) to the first parameter, but the documentation says that you must pass an array of Graphics. So you must havenew Graphic(...);
somewhere in your code and pass an array of those.Hope this helps!