Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get bounding box of a wms layer in leaflet

I want to fit the map on a specific wms layer in leaflet. for this, I try to get bounding box of the wms layer and then use the map.fitBounds(bbox) method. but I don't know how to get the bounding box of a layer! can somebody give me a solution? thanks

like image 886
mohammad fatemi Avatar asked Dec 10 '25 16:12

mohammad fatemi


1 Answers

Depending on your WMS server, the capabilities of your WMS layers might contain bounding box information.

Perform a GetCapabilities request (see e.g. https://wiki.state.ma.us/display/massgis/GeoServer+-+WMS+-+GetCapabilities ), parse that document (see e.g. https://github.com/w8r/wms-capabilities ), and locate the appropiate WMS layer(s). Bounding box information should be there.

Please note that Leaflet does not request the capabilities of the WMS server, and does not have built-in facilities for parsing it.

like image 165
IvanSanchez Avatar answered Dec 17 '25 00:12

IvanSanchez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!