Add gutter support to Leaflet's WMS tile layers to prevent icons and symbols from being cut off at tile boundaries.
Developed for OpenMapEditor and released as a standalone plugin for the Leaflet community.
WMS layers with point symbols or icons often have visual artifacts where symbols are clipped at tile edges. This happens because each tile is rendered independently by the WMS server.
This plugin implements OpenLayers-style gutter rendering:
- Requests slightly larger tiles (with overlap)
- Uses canvas to crop the gutter area
- Symbols spanning tile boundaries are fully rendered
// Instead of L.tileLayer.wms()
const wmsLayer = L.tileLayer.wms.gutter("https://example.com/wms", {
layers: "my-layer",
format: "image/png",
transparent: true,
tileSize: 512,
gutter: 64, // 64px overlap on each side
});
map.addLayer(wmsLayer);Download leaflet-wms-gutter.js and include it after Leaflet:
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script src="leaflet-wms-gutter.js"></script>- Expands the BBOX by
resolution × guttermap units - Requests tiles with dimensions
tileSize + (2 × gutter) - Uses canvas
drawImage()to crop and display only the center portion - Icons in the overlap area prevent cutoff at boundaries
| Option | Type | Default | Description |
|---|---|---|---|
gutter |
Number | 0 | Pixels of overlap on each side (typically 32-128) |
All standard L.tileLayer.wms options are supported.
See the included index.html for a working example, or view the live demo.
Works in all modern browsers that support Canvas 2D.
The canvas rendering has minimal performance impact. For layers without gutter (gutter=0), the plugin falls back to standard <img> tile rendering.
Inspired by OpenLayers' TileWMS gutter implementation. This plugin brings the same functionality to Leaflet.
- OpenLayers TileWMS Gutter Implementation - The original inspiration for this plugin
- OpenLayers Canvas Tile Renderer - Canvas cropping technique
MIT License - Copyright (C) 2025 Aron Sommer
See LICENSE section in the source code for full details.