Geographic Information Systems Asked by Shalinee Mishra on February 22, 2021
I have created a custom HTML page for data extract analysis using ArcGIS API, the API save the shapefile in zip format by default in my ArcGIS portal, so I just want to publish the shapefile(.zip) as a hosted feature layer using JavaScript.
To my knowledge you cannot publish a shapefile directly to AGOL via the ArcGIS JavaScript API (at least not with the Version 4.x JS API). If you still want to use JavaScript to accomplish this, you likely want to use the ArcGIS REST API. Specifically a combo of the Upload and the Publish Item endpoints.
Then you can just use whatever JS HTTP client (or just plain JS fetch) to make a POST request to each endpoint with the required request body params as outlined in the above links.
At a high level the workflow would be:
The tough part will be handling the async nature of all of this as, if this routine is to be used in a client facing application, it will keep the user sitting for a while. If performance isn't an issue, just await each request and run synchronously. Else, you may want to run that routine in a web worker or something to free up the UI.
Answered by Chaz on February 22, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP