2

There is a working example in Leaflet site for adding WMS Layer in Leaflet map at: http://leafletjs.com/reference.html#tilelayer-wms. But I don't see methods to provide the filter for bounding box.

Is there a way to provide bounding box filters for Leaflet WMS?

2 Answers 2

2

Leaflet does this on the fly depending on your location of viewport, viewport size, zoom and projection. It takes care of the math and which tiles to request. If you are interested in where this is done you can take a look at the source code for WMS Tile Layer. The bounding box isn't really defined until line 50.

If you need to create a custom bounding box it is just a matter of editing the source so L.TileLayer.WMS takes some new variables and replacing it with your own input.

**Note my link is at the current head of the git (28 May 2013), this could change.

2

You can use the option bounds to filter.

If set, tiles will only be loaded inside the set LatLngBounds.

L.TileLayer and L.TileLayer.WMS are both extending L.GridLayer, so the same options can used: https://leafletjs.com/reference-1.7.1.html#gridlayer-bounds

var nexrad = L.tileLayer.wms("URL.COM", {
    layers: 'LAYER_NAME',
    format: 'image/png',
    transparent: true,
    attribution: "Weather data © 2012 IEM Nexrad",
    bounds: L.latLngBounds([[1,0],[0,1]])
});

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.