The Magic IMAGE_RATIO Constant
When the map was first designed, it was built with a map bounds of [[0,0], [300,400]]
(as [y,x]
). That ended up creating a lot of whitespace on the sides. In order to fix the whitespace, the map bounds were reset to be [ 724 / 2, 966 / 2 ]
(divided by 2 because of how leaflet handles the image). 724 / 2 / 300
is what resulted in 1.2075
. However, since the images are not a perfect 4:3
ration, the function had to be once again updated to calculate the new aspect ratio. 483:362
is the rendered aspect ratio, so the new constant must be 724 / 2 / 362
, or 1.0006906077348
.
This new ratio is used by MapConstructor’s calcNewLocation
method which is called inside of the addElement
method to update every point on the map. It calls itself recursively if the passed argument is a nested array.