Detail in context
Keep the primary map visible while inspecting another layer through a focused comparison window.
- Drag to move and resize
- Full keyboard support
- Synchronized pan and zoom
- Works with Leaflet.NJImagery WMS layers
Open Leaflet plugin · Version 1.0.0
Reveal a synchronized second map layer inside an accessible window you can move and resize. This demo pairs Leaflet.NJImagery years 2020 and 1930.
Keep the primary map visible while inspecting another layer through a focused comparison window.
<script src="leaflet-nj-imagery.js"></script>
<script src="leaflet-layer-viewbox.js"></script>
const primary = L.tileLayer.njImagery("Natural2020").addTo(map);
const detail = L.tileLayer.njImagery("BlackWhite1930").addTo(map);
L.control.layerViewbox(primary, detail, {
initialPosition: [24, 24],
initialSize: [360, 260],
label: "1930 imagery"
}).addTo(map);
L.control.layerViewbox()Create a viewbox with primary and comparison layers.
setPosition() / getPosition()Move the viewbox or read its current location.
setSize() / getSize()Resize the window or inspect its dimensions.
setPrimaryLayer() / setViewboxLayer()Replace either layer after initialization.