[GIS] Applying bounding box filter in Leaflet WMS

extentsfilterleafletwms

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?

Best Answer

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.

Related Question