Nelly Barret
Nelly Barret

Reputation: 170

How to get diagonal of a bounding box?

I'm facing a simple problem but I don't know how to solve it!

I would like to get the diagonal of a boundingbox. I'm working on a Leaflet map and I have to get the diagonal of the current grip (emprise in French).

I'm able to get the current bounding box but I don't know to calculate the diagonal of this.

I know that the diagonal of a rectangle is diagonal = \sqrt(side1^2 + side2^2). But I don't know how to do this with coordinates (of my bounding box).

Upvotes: 0

Views: 1672

Answers (1)

Randy Casburn
Randy Casburn

Reputation: 14165

Leaflet supports both pixel based bounding boxes through Bound and Geo Coordinate bounding boxes through LatLonBounds

Use the Point.distanceTo(OtherPoint) method:

p1.distanceTo(p2);

Upvotes: 2

Related Questions