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?
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 .
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.
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