Greetings,
I'm trying to use featureLayer.source to create a feature layer with JSON. I create my featureLayer with an empty source and renderer and then try to add JSON data to it later. For some reason I'm getting the error:
"Source modifications will not propagate after layer has been loaded. Please use .applyEdits() instead"
I create the featureLayer like so:
let fl = new FeatureLayer({
popupTemplate: layer.popupTemplate,
fields:layer.fields,
objectIdField:"FACILITYID",
id:layer.id,
geometryType: "point",
source:[]
});
fl.minScale = layer.minScale;
console.log('fl.id: ' + fl.id)
const arcade = ` IIf($feature.NUM >100, true, false)`
var renderer = {
type: "unique-value",
valueExpression: arcade,
valueExpressionTitle: "Adoption Status",
uniqueValueInfos: [
{
value: true,
symbol: self.createSymbol("#00c3ff"),
label: "adopted"
},
{
value: false,
symbol: self.createSymbol("#ff002e"),
label: "unadopted"
}
]
};
mapView.map.add(fl)
Later on I try to add data to the feature layer using the source.add method like so:
let fl = self.state.mapView.map.findLayerById(layer.id)
fl.source.add({"attributes":{"FACILITYID":"DP76415003","INSTALLDATE":-2208970800000,"INLETTYPE":"Pipe","ACCESSDIAM":0,"adopted":"false"},"geometry":{"type":"point","x":-8769067.07037968,"y":4271765.250156212}})
the fl.source.add method is what is giving me the error.
Does anyone notice anythign that I'm doing wrong?
Thanks, Tyler