One should pray in a room with windows, and l’chatchilah it is good that a window facing Jerusalem be open (Shulchan Aruch 90:4). When someone is in a place with no windows, he should pray in a well-lit place, since some explain that the reason for praying in a room with windows is that the light settles the thoughts of the person praying (Talmidei Rabbeinu Yonah).
In a synagogue, there are those who enhance the mitzvah by building twelve windows (Shulchan Aruch 90:4). The windows should be high, so that it is possible to see the sky and not see things that may distract people from the prayer service.
A person should not recite the Amidah in open areas, and one who prays in an open place is called insolent (Berachot 34b). The reason for this is that in an open area one’s thoughts scatter, and in a closed and modest place the King’s awe is upon him, and his heart is humbled (Shulchan Aruch 90:5). Furthermore, in an open space, people may pass by him and disturb his concentration.
Those who are traveling are allowed to pray along their way, and if there are trees there, it is better to pray between them (Mishnah Berurah 90:11). Similarly, it is preferable to pray next to a wall and not in a completely open area (Eshel Avraham Butshatsh 90:5). It is even better to pray in a courtyard surrounded by walls, since the main principle is to have a nearby partition, even without a ceiling (Mishnah Berurah 90:12).
One may pray in the plaza of the Kotel (the Western Wall) because it is surrounded by walls on three sides. Moreover, the exalted holiness of the site strengthens one’s love and awe of Hashem causing one’s prayer to be said with more kavanah. Yitzchak Avinu practiced this way as well. He recited Minchah on Mount Moriah, the gateway of prayer, which was then an open field, as it says, “Yitzchak went out to meditate in the field” (Genesis 24:63; Berachot 26b).
When it is not possible to pray in a synagogue, for instance, when it is occupied by a different minyan, it is permitted to pray behind the synagogue, on condition that one faces the direction of the synagogue and Jerusalem. It is also permitted to pray alongside the synagogue when facing Jerusalem. However, it is forbidden to pray in front of the synagogue because if he faces the direction of Jerusalem, his back will be disrespectfully turned towards the synagogue, and if he faces the synagogue, his back will be turned to Jerusalem (Shulchan Aruch 90:7).