Is it possible to create an empty feature layer that is populated by client side data later on?
I've only been able to create FeatureLayer when I have data to populate
Solved! Go to Solution.
Hi there,
Yes it can be done easily. You can create an empty client-side FeatureLayer by setting its source property to an empty array. Then you can add and remove features from it by calling applyEdits method.
This is explained here: https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#creating...
This sample shows the process: https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection-edits/
Hi there,
Yes it can be done easily. You can create an empty client-side FeatureLayer by setting its source property to an empty array. Then you can add and remove features from it by calling applyEdits method.
This is explained here: https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#creating...
This sample shows the process: https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection-edits/
I've tried doing a empty [] for source previously but then it just throws this error: table feature layer can't be displayed. Hence this question :).
Hi there,
Please read the doc from the link I provided above. Creating a FeatureLayer section in FeatureLayer doc has a section called Add an array of client-side features. This section explains all required schema properties you need to set to successfully initialize your client-side FeatureLayer. You must set the geometryType property in the class constructor to let the api know that you are creating a spatial FeatureLayer. Otherwise, the api assumes you are creating a non-spatial FeatureLayer and non spatial FeatureLayer cannot be added to the map.
Yep read it through, eventually came across another similar post that resolved it through GeometryType (as per your message here)