[GIS] openlayers 3 how to get map scale using zoom level

openlayersscale

is there a way to get the map scale on openlayers 3 the map change zoom level ?

i found a site that converts from map distance to scale

zoomlevel : 20
to
map scale : 1:50000.

https://www.maptools.com/scale_calculator

is there a way in openlayers to get the map scale using the zoom level as map distance

Best Answer

The easy thing you can do is to display a scale line, as demonstrated in this example.

var scaleLineControl = new ol.control.ScaleLine();

Computing a correct fractional scale is quite complicated, because you would have to take into account the resolution of your screen, which of course differs from one device to another. This control did exist for OpenLayers 2.