Offer No. 1
You can create a clip mask and change its rect in the opposite direction of your pan.
Something like http://jsfiddle.net/gaby/dgWZk/23/
var overlay = { top: 50, left: 50, width: 200, height: 200 } map.on('move', repositionMask) ; map.fire('move'); function repositionMask() { var po = map.getPixelOrigin(), pb = map.getPixelBounds(), offset = map.getPixelOrigin().subtract(map.getPixelBounds().min); $(layer02._container).css({ clip: 'rect(' + (overlay.top - offset.y) + 'px,' + (overlay.left + overlay.width - offset.x) + 'px,' + (overlay.top + overlay.height - offset.y) + 'px,' + (overlay.left - offset.x) + 'px)' }); }
The problem is that the flyer methods do not expose the animation variables when panning with inertia, and therefore we cannot simulate this yet ... therefore I disabled the inertia cards.
Also, the problem with scaling / disabling is that during the animation, the mask also zooms in / out (but is fixed after the animation finishes or you can also set zoomAnimation:false )
Offer No. 2
An alternative solution is to create a second card and apply / synchronize it
something like http://jsfiddle.net/gaby/dgWZk/24/
<div id="container"> <div id="map"></div> <div id="overlay"></div> </div>
with
#container { position:relative; height:500px; } #map { height: 500px; position:absolute; top:0; left:0; right:0; bottom:0; } #overlay { width: 200px; height: 200px; position:absolute; top:50%; left:50%; margin-left:-200px; margin-top:-200px; outline:1px solid green; pointer-events:none; }
and
var map = new L.map('map',{ inertia:false }).setView([51.505, -0.09], 13); var overlay = new L.map('overlay', { zoomControl: false, inertia: false, keyboard: false, dragging: false, scrollWheelZoom: false, attributionControl:false, zoomAnimation:false }).setView([51.505, -0.09], 13); var layer01 = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map); var layer02 = L.tileLayer('http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg').addTo(overlay); map.on('move', function () { var offset = overlay._getNewTopLeftPoint(map.getCenter()).subtract(overlay._getTopLeftPoint()).subtract([100,100]); overlay.fire('movestart'); overlay._rawPanBy(offset); overlay.fire('move'); overlay.fire('moveend'); }).on('zoomend', function () { overlay.setView(map.getCenter(), map.getZoom(), true); map.fire('move'); }); $(window).resize(function () { overlay.setView(map.getCenter(), map.getZoom()); map.fire('move'); }); map.fire('move');