I'm trying to draw a rectangle polygon on the map having a defined size in meters.
Background is: I want to show the user a rectangle of a defined paper size (e.g. DIN A4) on the map to choose a region to print for a specific scale (e.g. 1:25000).
My math to calculate the size in meters that would be visible on the paper is:
widthInMeters = paperWidthInCm * (scale/100)
Given the width of A4 landscape (29.7cm) I'd get 7425 meters (29.7 * (25000/100)). Height would be 7425 * 0.7070 = 5249m
Now I want to draw a rectangle of this size (7425m x 5249m) on the map.
My first try was to just set the extent accordingly because the coordinates units (Web Mercator EPSG:3857) are in meters. But that, I think, would only work directly on the equator. Further up north or south this does not work at all because of projection distortion.
Given a defined width and height in meters and a center (or top left) coordinate how can I create an appropriate geometry covering that area?
getPointResolution
.