added layerToMapCoordinates for rectangles, and more detailed comments