1

I've created a leaflet map and use L.tileLayer.wms to load my wms layer. I dont want to load all data on my map instead i need to load data based on bbox.I use this line for sending wms request to geoserver :

L.tileLayer
  .wms(elm.GIS_LayersAddressMapServer.trim(), {
    layers: elm.GIS_LayersName,
    format: "image/png",
    transparent: true,
    tiled: true,
    maxZoom: 25,
    bbox: map.getBounds().toBBoxString(),
  })
  .addTo(map);

but in network console i have this :

http://localhost:8080/geoserver/cite/wms
  ?service=WMS
  &request=GetMap
  &layers=cite%3APTL_Tower
  &styles=
  &format=image%2Fpng
  &transparent=true
  &version=1.1.1
  &tiled=true
  &bbox=25.0927734375%2C22.836945920943855%2C78.22265625000001%2C41.50857729743935
  &width=256
  &height=256
  &srs=EPSG%3A3857
  &bbox=5165920.119625352,4226661.916057106,5322463.153553394,4383204.949985149

as you see bbox is sent twice and doesn't show me anything. How can i handle this problem ?

  • 2
    L.tileLayer.wms creates it's own bbox parameter when creating wms request, so specifying additional one won't help. Instead try with Leaflet's bounds option. – TomazicM May 19 at 6:56
  • TomazicM - what do you mean by bounds ?. you mean i ought to create wms request and pass bounds to it ? could you please send me a sample . – hamed May 19 at 7:01
  • 1
    L.tileLayer.wms layer inherits bounds option of general L.GridLayer layer, see leafletjs.com/reference-1.6.0.html#gridlayer – TomazicM May 19 at 7:43
  • TomazicM - tnx alot. but i still can't find any proper method to handle my problem ! – hamed May 20 at 7:28
  • 1
    Edit your question and describe what have you tried and still does not work as expected. – TomazicM May 20 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.