Hello Andrea,
I hope this finds you well!
Unfortunately, there isn't a way to get rid of one or more layers within a Hosted Feature Service without deleting and republishing the service OR using ArcGIS Online Assistant (ArcGIS Online Assistant). If you wish to use ArcGIS Online Assistant, I would recommend making a copy of the service before you make any changes. You should proceed with caution using this workflow, as if its not done correctly, problems may occur with the service.
Below is the workflow for using ArcGIS Online Assistant:
- In ArcGIS Online, go to the Item Details of your Hosted Feature Service. Select the particular layer you'd like to remove and it should take you to a URL similar to this: https://services.arcgis.com/Wl7Y1m92PbjtJs5n/arcgis/rest/services/test_remove_layer/FeatureServer/0
- The /FeatureServer/0 is important, as you'll need to know this specific number later.
- Once you know the specific number of the layer within your Hosted Feature Service, we can move over to ArcGIS Online Assistant.
- Sign in with your ArcGIS Online credentials.
- At the top, select "I want to..." and then select "View an Item's JSON".
- On the left-hand side, navigate to your Hosted Feature Service that needs alteration and select it. You'll notice the service JSON populate on the right-hand side.
- Scroll down to the start of the "Data" section of the JSON. Start to look for "id" : 0, "id" : 1, "id": 2, etc. Look for the id number that corresponds with the number in the URL (from step 1), this is the id we're going to remove.
- At the top of the Data section, select the "pencil" icon to start editing. Start with the open bracket above "id" : # and highlight all the way down to the close bracket of the section. Proceed to delete this section and make sure the JSON brackets are aligned correctly before saving the section.
- After you've deleted the section, this specific layer will be deleted and you should be good to go.
I know it's a long one, but if you wish to take on this specific workflow, I've recorded myself performing the workflow. You can access the video here: https://www.screencast.com/t/QlDosHbdNJ
Cheers,
Joe