Fiqh-us-Sunnah Volume 1, Purification and Prayer, Fiqh 1.017.

Section : He should move and hide himself from others while going to the bathroom.

This is especially true in the case of defecation, so others can not hear noxious sounds or smell bad odours. Said Jabir, “We were journeying with the Messenger of Allah, upon whom be peace, and he would only relieve himself when he was out of sight.” (This is related by Ibn Majah.) Abu Dawud records that, “When he wanted to relieve himself, he would go where no one could see him.” He also related, “When the Messenger of Allah, upon whom be peace, went out he would go very far away.”