The walled-in foreground in the photo below is the portion of Jerusalem that was the City of David. The temple behind it did not yet exist. It was built after David’s death by his son, Solomon.
David then took up residence in the fortress and called it the City of David. He built up the area around it, from the supporting terraces inward. And he became more and more powerful, because the LORD God Almighty was with him. (2 Samuel 5:9-10)
Below is what remains of the City of David today. The temple area (the Temple Mount) is to the left in this picture. The hill in the background is the Mount of Olives where Jesus often spent time relaxing and praying. The Garden of Gethsemane is on that Mount.
Click on the wall on the far side of what’s left of the City of David, to see the ruins ~ and the view ~ that’s on the other side of it.