onaci/leaflet-geotiff-2

calculate time L.LeafletGeotiff actually run

Closed this issue · 1 comments

hi, can you help me
i need to load multiple tiff files in leaflet . My logic is when i press button, i do : loads another tiff file, removes old layer group and re-add new tiff file to new layer group. But when i do it, it take about 3-4s for my tiff actually add to my map, therefore my map have 3-4s display bank (i want this old tiff still display )

So i want to know exactly what is take time here. (L.leafletGeotiff or layer.addTo(map))
i try calculating the time like this code bellow

var layer = L.leafletGeotiff(url, options); var t1 = performance.now(); layer.addTo(map); layer.on("load",function() {console.log(performance.now()-t1) });
it print about 4s

but when i change this code to

var layer = L.leafletGeotiff(url, options) //wait about 4 second then when click button this layer attack to my map onclick (){ var t1 = performance.now(); layer.addTo(map); layer.on("load",function() {console.log(performance.now()-t1) }); }
it print about 0.3 s

You could use the performance tool in your browser's DevKit. It will create a graph where you can analyze what functions are being executed at any time.