search

Home  >  Q&A  >  body text

javascript - The actual distance between two objects is 30m. How many pixels should the distance be on a 1:100m electronic map?

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?

天蓬老师天蓬老师2814 days ago606

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-05-18 10:59:44

    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 .

    reply
    0
  • 黄舟

    黄舟2017-05-18 10:59:44

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

    reply
    0
  • Cancelreply