Neurons of the medial entorhinal cortex (MEC) provide spatial representations critical for navigation. In this network, the periodic firing fields of grid cells act as a metric element for position. The location of the grid firing fields depends on interactions between self-motion information, geometrical properties of the environment and nonmetric contextual cues. Here, we test whether visual information, including nonmetric contextual cues, also regulates the firing rate of MEC neurons. Removal of visual landmarks caused a profound impairment in grid cell periodicity. Moreover, the speed code of MEC neurons changed in darkness and the activity of border cells became less confined to environmental boundaries. Half of the MEC neurons changed their firing rate in darkness. Manipulations of nonmetric visual cues that left the boundaries of a 1D environment in place caused rate changes in grid cells. These findings reveal context specificity in the rate code of MEC neurons.