I'm trying to do a business logic on a map whenever some events are done by a user.
I'm able to get working drag , dblclick and zoomstart events.
But load event is not getting fired for me. (On Browser load initially)
My sample code below :
var map = L.map('map').setView([34.7320,-86.5966], 14);
map.on('load drag dblclick zoomstart', function() {
// My business logic goes here.
});
The load event is firing before the load event handler is attached, as you're running setView right after instantiation.
This, in the other hand, is what you want:
var map = L.map('map').on('load', function(){......}).setView([34.7320,-86.5966], 14);
Most helpful comment
The
loadevent is firing before theloadevent handler is attached, as you're runningsetViewright after instantiation.This, in the other hand, is what you want: