saving layer state, so we know when to display the loading spinner