How to tell when all visible tiles have fully loaded?

Forest Katsch picture Forest Katsch · Mar 9, 2014 · Viewed 15.2k times · Source

Is there an event (or other method) to detect when all visible tiles have been downloaded and displayed with leaflet? (Similar to Google Maps event that is called when all visible map tiles are loaded, but for leaflet instead)

Answer

Forest Katsch picture Forest Katsch · Mar 10, 2014

Solved. Bind the "load" event on the tile layer. Example:

var tile_layer=L.tileLayer(tile_url,{
  attribution: "Map data &copy; <a href='http://openstreetmap.org'>OpenStreetMap</a> "+
    "contributors, <a href='http://creativecommons.org/licenses/by-sa/2.0/'>CC-BY-SA</a>.",
  maxZoom: 18
});
tile_layer.addTo(map);
tile_layer.on("load",function() { console.log("all visible tiles have been loaded") });