Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a LatLngBounds around a LatLng point with a distance in meters?

Tags:

leaflet

I would like to create a square (LatLngBounds) around a central point (LatLng) at X meters.

like image 298
XcinnaY Avatar asked Jan 23 '26 14:01

XcinnaY


1 Answers

Use the L.LatLng.toBounds() method, e.g.

var center = L.latLng(40,-3);
var bounds = center.toBounds(500);

or

var bounds = L.latLng(40,-3).toBounds(500)
like image 123
IvanSanchez Avatar answered Jan 26 '26 21:01

IvanSanchez