Praying and learning Torah near a bathroom:
It is Biblically forbidden to learn Torah or pray within the sight or within a four cubit radius [i.e. two meters] of the walls of a bathroom, just as it is prohibited to learn or pray within the sight or within four cubits of actual excrement. This restriction however only applies to bathrooms that do not share walls with other rooms, such as mobile bathroom usually found by events, or bathrooms found in parks which are housed in their own designated building. It is forbidden to even think Torah within the above area. This law applies even if the door of the bathroom is closed, and even if the bathroom is clean of any excrement.
A bathroom which shares its walls with other rooms: Any walled bathroom which shares its walls with other rooms, [such as a bathroom that is in a house of which the bathroom wall is also a house wall], do not have the Halachic status of a bathroom and it is thus allowed for one learn Torah or pray within a four cubit radius of its walls and within its sight. (Nevertheless, one may not learn or pray [within four cubits of] the actual toilet, or when he is facing the toilet and the toilet is within his sight.)
It is permitted to learn and pray near the walls of a bathroom that is in a house or building. One may not pray or learn within two meters of the toilet if the bathroom door is open. Likewise, one may not pray if the toilet is within his sight. It is forbidden to pray within two meters of the walls of a mobile bathroom, or external bathroom building. Likewise, one may not pray or learn when this bathroom is within one’s sight.
May one pray or learn Torah at a park if he can see the bathroom walls?
If the bathroom in the park is its own structure, such as a mobile bathroom, or a building that is designated only as a bathroom, then one may not learn or pray within its four cubits [i.e. two meters]. Likewise, one may not learn or pray if the bathroom is within one’s view, even if he is further than four cubits. One is to thus turn his back to the bathroom walls to be allowed to pray and learn.
May one pray or learn in a house/Shul if he can see a mobile bathroom from his open door/window?
This matter is disputed in Poskim. Practically, although the main ruling follows the lenient opinion, nevertheless it is best to be stringent that the bathroom not to be within one’s sight. [This stringency however is only required if the window or door is open, as according to all opinions there is no issue in seeing the mobile bathroom through a closed transparent window or door.] Likewise, according to all it suffices to close one’s eyes when inside the house even if one is facing it, and at night, if one cannot see the bathroom due to lack of light, it is permitted to pray or learn in one’s house even if one is facing it through an open window or door.
May one pray or learn in his house if the bathroom door is open?
If one can see the toilet or the floor, and the floor is dirty with urine, then one may not do so. Likewise, if he is within two meters of the toilet, or the dirty floor, he may not do so. If one cannot see the toilet and is not within two meters of the toilet then it is permitted.
 Admur 83:1 based on Taz 83:1; Elya Raba 83:2; Soles Belula 83:1; Chayeh Adam 3:11; Chesed Lealafim 83:2; Ruach Chaim 79:2; Ketzos Hashulchan 10:11; Kaf Hachaim 83:4; M”B 83:5; Although many Poskim today are lenient for various reasons, as mentioned below, practically the Sheivet Halevy 4:10 rules stringently and so is implied from Admur and other Poskim above that do not mention the distinctions below.
The Michaber 83:1 rules that it is forbidden to pray or learn Torah near an area designated for bathroom use. If however the bathroom contains walls then it is permitted to learn or pray near the bathroom without hesitation. The Michaber does not differentiate between walls of a house or walls of a mobile bathroom, and thus according to him all bathrooms with walls do not have a status of feces. In the Beis Yosef he writes that even if the walls do not reach 10 Tefach from the ground it is permitted so long as one cannot see the floor of the bathroom. The Magen Avraham [83:1] argues on the Michaber and rules that one is to be stringent to forbid learning or praying near the walls of any bathroom even if the walls are ten Tefach high [and even if they share walls with other rooms]. Those that desire to be lenient may only do so if the walls are ten Tefachim high and the bathroom does not reek of feces or urine. The Taz [83:1] likewise argues on the Michaber and rules that it is forbidden to learn or pray even near a walled bathroom. However the Taz concludes that in his opinion this only applies by bathrooms that have their own walls as opposed to a bathroom found in a building that shares walls with other rooms. Admur, as well as all the Poskim listed above, rule like the Taz.
Other Opinions: Some Poskim are lenient and rule that one may always learn and pray outside a bathroom, near the walls [Michaber ibid; Aruch Hashulchan 83:8 [being the walls are considered like walls of a house]; Eretz Tzevi 1:11 and Chazon Ish 17:1 [being the feces do not touch the actual walls of the bathroom]; Salmas Chaim 104 [being that the feces are flushed down right away and is hence not considered a bathroom]; Daas Torah and Halichos Shlomo 20:38 [Being that the walls today are made of a few sheets of plaster]; See also Shulchan Hatahor 83:2; Ashel Avraham Butchach; The Sheivet Halevy 4:10 agrees with ruling of Admur that it is forbidden and argues on the Chazon Ish saying one cannot novelize such a distinction between walls that become dirty and those that don’t. Piskeiy Teshuvos 83:2 rules leniently based on all the above Poskim.]
Today’s bathrooms hat have the feces flushed down right away: In 83:4 Admur rules that a bathroom which is made in a way that the feces and urine immediately leave to a different area are not considered a bathroom. Some [Salmas Chaim; Piskeiy Teshuvos ibid] rule based on this that our bathrooms are not considered bathrooms and it is hence permitted to learn Torah near them even if they are a separate building that do not share walls. Practically however one cannot compare our bathrooms to the above bathrooms in discussion being that the feces do not leave right away and remain in the toilet until it is flushed.
 The reason for distancing from the actual walls is because the walls themselves are considered like a “potty of feces” being that this is the use that they have been designated and used for. [ibid]
 Lit. near
 Parentheses in original; So writes also Piskeiy Teshuvos 83:2; See Chikrei Halachos 6 p. 42 for explanation of the doubt here in Admur; Vetzaruch Iyun as to the intent of Admur here: Is he referring to a case that the door is open and in such a case one may not be within four cubits of the toilet or within its sight, or does he refer to even a case that the door is closed? Also how does this ruling not contradict the ruling in 79:5 that when the Tzoa is in a different area one may be within four cubits of it, even if it is visible. Vetzaruch Iyun. To note the Ketzos Hashulchan ibid omits this ruling in his summary and simply writes one may learn and pray near such a bathroom.
 Based on above ruling
 Admur 79:5 and Michaber 79:2 regarding having feces in the next room and according to Admur the same applies in this case of mobile bathrooms outside one’s home, being that a mobile bathroom is viewed as feces according to Admur ibid.
 Regarding a person being in a different room than the feces, Admur ibid rules as follows: If a person is in one room reading the Shema and the feces are in another room, then even if the door is opened between the two rooms and he is sitting by the opening which is near the feces, nevertheless it is permitted to read the Shema in that area so long as he does not smell the feces. The reason for this is because the opening of the room is considered as if it is closed, being that it contains doorposts [Lit. Gifufim] that separate it from the room that contains the feces. [1st opinion in Admur ibid and Michaber ibid; Rosh Brachos 3:46] However there is an opinion [Rashba Brachos 25a; 2nd opinion in Admur and Michaber ibid] that rules it is forbidden to read the Shema while the feces is within one’s view, even when it is in a different domain. Practically, the main ruling follows the former opinion, as since the feces is in another room it is not relevant whether he can see it, as it is considered like feces in a glass container of which all agree that there is no prohibition in seeing it. [Thus, the feces may be within 4 amos of the person outside the room and the door may be open with the visible feces.] Nevertheless, it is proper to suspect for the latter opinion [and not have the feces within one’s sight]. [Admur ibid; Beis Yosef; Ateres Zekeinim 79:2]
 As this is similar to feces that are in a glass container of which all agree do not contain a prohibition.
 Admur ibid; M”A 79:8
The reason: As since he is in a different domain and does not physically see it, all agree it is permitted. [ibid]
 See Piskeiy Teshuvos 83:2