javascript - The actual distance between two objects is 30m. How many pixels should the distance be on a 1:100m electronic map?
天蓬老师
天蓬老师 2017-05-18 10:57:44
0
2
566

As mentioned in the title.

There are two objects 30 meters apart in display life. If these two objects are marked on a 1:100m map, how many px should the distance between them be?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
小葫芦

First of all, we need to know how many pixels the length of 1cm is equal to on the screen. This is easy to find with the help of the centimeter unit in CSS.

var p = document.createElement('p');
p.style.width = '1cm';
document.body.appendChild(p);
var pxPerCm = p.offsetWidth;

The distance of 30 meters should be 30cm on a 1:100m map. The actual rendered pixel distance is 30 * pxPerCm .

黄舟

This specific value should be calculated based on the ratio and zoom level of your map display

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template