4374754:指的是地球赤道上一度约等于此距离,单位米。
96DPI:指一英寸(25.4毫米)内存在96个像素点数,DPI(Dots Per Inch)。
resolution: 是计算地图显示区域当前视野的单位地理距离(米/度)与屏幕像素之间的比例尺。
result:96DPI像素内一共多少米。也就是比例尺。
getScaleFromResolution() {
const map = this.map
const bbox = map.getBounds()
const wLng = bbox.getWest()
const eLng = bbox.getEast()
const canvasWidth = map.getCanvas().clientWidth
const resolution = (eLng - wLng) / canvasWidth // 度 1px有x度
const result = resolution * 96 * 4374754
return result
}