TransWikia.com

Choosing correct zoom level to display given area in square km using Leaflet?

Geographic Information Systems Asked by SuprMan on January 23, 2021

I would like to set the zoom on a Leaflet map based on an area (in km^2).

I am looking for a simple function that would approximately convert an area of
510,064,472 km to zoom level 0 and (if I read the table of zoom level at https://wiki.openstreetmap.org/wiki/Zoom_levels correctly) an area of 12,321 to zoom level of about 8.5 and so on.

One Answer

An approximation of a solution that works up to about zoom level 10:

Math.round(Math.abs(Math.pow(area,1/8.5) - 12))

(Since OSM uses a mercator projection the surface area of the OSM world seems to be closer to 1,500,000,000 KM^2 then 510,064,472)

I don't consider this a good solution and I am still hoping to find a better one.

Answered by SuprMan on January 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP