Is there a way to automatically retrieve the DPI value of an OpenLayers page? The goal is to automatically retrieve the map scale from this code:

function mapScale (dpi) {
    var unit = map.getView().getProjection().getUnits();
    var resolution = map.getView().getResolution();
    var inchesPerMetre = 39.37;

    return resolution * ol.proj.METERS_PER_UNIT[unit] * inchesPerMetre * dpi; }

I suppose it should be possible to consider the ScaleLine function which automatically gives the scale.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.