The increasing technological control of two-dimensional materials has allowed the demonstration of 2D lateral junctions, which display unique properties that might serve as the basis for a new generation of 2D electronic and optoelectronic devices. Notably, the chemically doped MoS$_2$ homojunction, the WSe$_2$-MoS$_2$ monolayer and MoS$_2$ monolayer/multilayer heterojunctions, have been demonstrated. Here we report the investigation of 2D lateral junction electrostatics, which differs from the bulk case because of the weaker screening, producing a much longer transition region between the space charge region and the quasi-neutral region, making inappropriate the use of the complete-depletion approximation. For such a purpose we have developed a method based on the conformal mapping technique to solve the 2D electrostatics, which is widely applicable to every kind of junctions, giving accurate results for even large asymmetric charge distribution scenarios.