Leaflet map-event 'load' does not fire
Or use inline
var mymap = L.map('YOUR_MAP_ID').on('load', onMapLoad).setView([51.505, -0.09], 13);
function onMapLoad(){
console.log("map loaded");
}
I suggest you to use the "whenReady" method available in Leaflet 1.0.1
var callBack = function () {
console.log("Map successfully loaded");
// do some stuff
};
mymap.whenReady(callBack);
Put the mymap.on('load', onMapLoad);
event handler before you actually load the map (with map.setView...
).
So your actual code should look like,
var mymap = L.map('mapid');
mymap.on('load', onMapLoad);
mymap.setView([51.505, -0.09], 13);
Source : Github Issue