Leaflet: load event not firing in leaflet

Created on 25 Jun 2015  路  1Comment  路  Source: Leaflet/Leaflet

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.
  });

Most helpful comment

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);

>All comments

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);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ceremony64 picture Ceremony64  路  30Comments

tmcw picture tmcw  路  22Comments

tannerlinsley picture tannerlinsley  路  28Comments

zzolo picture zzolo  路  31Comments

danzel picture danzel  路  37Comments