Atlaslog
Atlaslog / Leaflet / API reference / WMS
Leaflet · API reference

WMS

Quick answer

L.tileLayer.wms builds OGC GetMap requests into a tiled layer, connecting Leaflet to GeoServer and MapServer publications. It forwards layers, styles, format, version and transparency parameters, and setParams changes them without rebuilding the layer. Large tileSize values reduce request counts, and the uppercase option helps with legacy servers.

Last verified 2026-11-03 · Leaflet 1.9.4 · Cite this page
L.tileLayer.wms( baseUrl , options ) → TileLayer.WMS
Key points
Example
var wms = L.tileLayer.wms('https://gis.example.com/geoserver/wms', {
  layers: 'city:roads,city:water',
  styles: '',
  format: 'image/png',
  transparent: true,
  version: '1.3.0',
  attribution: '© 城市地理信息中心',
  opacity: 0.8,
  maxZoom: 18
}).addTo(map);

/* 切换图层时不要重建,setParams 只改参数并重绘 */
document.getElementById('switch').addEventListener('click', function () {
  wms.setParams({ layers: 'city:buildings' }, true);
  wms.redraw();
});

/* 打印实际发出的 GetMap 地址,排查 400 时很有用 */
console.log(wms.getTileUrl({ x: 6745, y: 3104, z: 13 }));
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). WMS. https://www.jingweizhi.com/en/leaflet/api/wms.html (accessed 2026-11-03).