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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With