i have the exact same question.
ideally, i'd like to use one of the pre-built templates for this, instead of api programming.
i just want my visitors to be able to turn layers on and off.
Not sure if these are called "layers". I'm talking about the external data i added to the map.
If you go to the "Content" tab in the arcgis online map editor, each external datasource is listed. Each one has a checkbox. If you uncheck the checkbox, that data is removed from the map display. That exactly what i need, but in an embedded map on my website.
thanks!