Spatially Resolved Band Gap and Dielectric Function in Two-Dimensional Materials from Electron Energy Loss Spectroscopy