I have designed a map in QGIS that I'm putting into OpenLayers. In QGIS they use scale, where it's just a ratio of real world units to map units. In OpenLayers, however, they use resolution.
I have read this post on GIS SE, but I'm not that advanced, and I couldn't really follow along as I'm not sure what DPI, or resolution for that matter, is. The accepted answer said that resolution is meters per pixel, but what is a pixel? Is it a CSS pixel or screen resolution? If it was based on screen resolution, wouldn't min/max resolution be dependent on user screen resolution? Either way, how do I take a specific map scale and find the corresponding OpenLayers resolution?
Best Answer
I do not propose this as a solution to the problem, just practical solution I cooked up a few years ago. Solution is some kind of a hack based on displayed
ol.control.ScaleLine
control. So the solution to work, it needs active OL map with scale line control displayed. Don't ask me about theory behind it, I forgot where I picked all the pieces to put it together.This is the JS code: