Javascript examples for Leaflet:Configuration
keep old tiles until each new tile is loaded in Leaflet?
<html> <head> <title>Prevent flickering on redraw</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"> <script type="text/javascript" src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script> <style id="compiled-css" type="text/css"> #map { height: 180px; } </style> <script type="text/javascript"> window.onload=function(){//from www . j av a2s . co m var map = L.map('map').setView([51.505, -0.09], 13); var layer2 = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: 'prevent flickering', maxZoom: 18 }).addTo(map); var layer = L.tileLayer('http://{s}.tiles.mapbox.com/v3/examples.map-i86knfo3/{z}/{x}/{y}.png', { attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery ? <a href="http://mapbox.com">Mapbox</a>', maxZoom: 18 }).addTo(map); map.on('click', function(e) { layer2.bringToFront(); layer.on('load', function(e) { console.log('loaded'); layer.bringToFront(); }); layer.redraw(); }); } </script> </head> <body> <div id="map"></div> </body> </html>