Electrostatics of two-dimensional lateral junctions