In the Portal Viewer, we can add data from portal, from url, or from local file.
In WAB developper edition, there is a widget called "addData" : https://developers.arcgis.com/web-appbuilder/guide/widget-add-data.htm
I don't find a way to do the same in API 4.12. Is there a way to do that ?
Thanks
Solved! Go to Solution.
Hi Jub, I am unaware of a built in way to allow the user to add items from Portal. However, using the service url you can try to build it yourself. I can create a sample for this
Edit:
Here is the sample: https://codepen.io/benesri/pen/QWLYRoK?editors=1000
Note that there is no error handling and it assumes everything is a FeatureLayer, but it's something that you can build on
In this thread Munachiso was able to convert the sample to 4x
Here is the github for the 4x version
You do need AGOL or Portal for this to work. Also you may need the resource proxy to remedy any CORS errors you may get. This sample is based on the 3.x, so a lot of the code from that sample is the same with some changes for 4.x.
- Munachiso
Thanks, this is a good method to add data from local files. An other way to upload data is : Create a FeatureLayer with client-side graphics | ArcGIS API for JavaScript 4.12
But is there a way in 4x to interact with Portal content ? I mean, is it possible the end-user to load data from Portal (like in Portal Viewer or WAB addData widget) ?
Thanks
Hi Jub, I am unaware of a built in way to allow the user to add items from Portal. However, using the service url you can try to build it yourself. I can create a sample for this
Edit:
Here is the sample: https://codepen.io/benesri/pen/QWLYRoK?editors=1000
Note that there is no error handling and it assumes everything is a FeatureLayer, but it's something that you can build on
Thanks Ben, this sample works perfectly