Limit map inside boundaries

8 Views Asked by At

I have a Slippy Map, which is just a group of images, that changes depending on the zoom.

I want to limit the map inside a rectangle, but I'm not sure how to do that.

I tried boundary * zoom, but I suppose that's not how Latitude and Longitude work.

Any map is max of 90 Longitude and 180 Latitude. But my map is square, and I want to limit the map inside that square. But changing the limit values doesn't give a clear idea on how the limits are applied.

Say I have the map at zoom 2.9, and I want the maximum NE edge to be at 160 Latitude, and 80 Longitude. How can I translate these values, using the zoom value, to boundaries in the new zoom? Is there a calculation I can make to translate these values?