S
S
sumrakx2018-07-17 14:07:30
JavaScript
sumrakx, 2018-07-17 14:07:30

How to get layer size in meters?

Hello. There is a layer in the L.CRS.Simple coordinate system on the map. The layer must somehow be changed in meters

[if you calculate the size of the layer in width, you get 14900 km, which is a lot]
. That is, let's say there is known data on how many meters the width and height should be
"Width": 0.008863744, "Height": 0.008372224
, in meters. The pixel size is also known in meters.
6.4e-8
. Can I somehow use this for calculation?
I tried to use bounds to bind the layer to the required latitude and longitude, but it only displays a small piece of the map. Do I need to use bounds here at all, or do I need to use something else here?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Andreevich, 2018-12-06
@RomanDillerNsk

sumrakx , you first need to change the coordinate system. If you use a background for example Google, and overlay a layer with a picture on it, for example imageOverlay, then this layer can have:

let one = tile.getBounds()._northEast;
        let two = tile.getBounds()._southWest;

These will be the coordinates of the corners - northwest, and southeast, in a simple way you will get, for example, northeast, and then you can do it like this:
getWidthAndHeight(southWest, southEast, northEast) { // получаем длины вертикальной и горизонтальной линии

    this.points = [

      new L.LatLng(southWest[0], southWest[1]),
      new L.LatLng(southEast[0], southEast[1]),
      new L.LatLng(northEast[0], northEast[1])			

    ];

    this.data.width = +(this.points[0].distanceTo(this.points[1])).toFixed(0);
    this.data.height = +(this.points[1].distanceTo(this.points[2])).toFixed(0);

  }

height and width in meters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question