Petra Barus
Petra Barus

Reputation: 4013

Leaflet map event equivalent to Google Map "idle" event

I can't seem to find the map event in Leaflet that equals to Google Map "idle" event.

The definition of Google Map event "idle" is "This event is fired when the map becomes idle after panning or zooming."

https://developers.google.com/maps/documentation/javascript/reference#Map

I tried Leaflet "viewreset", "load", "blur", "focused", "moveend" but they are really different from Google Map's "idle".

The best I can do is to use this

var foo = function(e){
   console.log('Hello');
}
map.on('load', foo);
map.on('moveend', foo);

Just want to find out if I'm reading the manual wrong. Or even if there is no event equivalent to Google Map's 'idle', is there a better way to implement it?

Upvotes: 6

Views: 2949

Answers (1)

Ilja Zverev
Ilja Zverev

Reputation: 953

There is no "idle" event in Leaflet library, though the description seems resemblant of "moveend" (there is nothing about map initialization).

As you yourself found out, you can use both "load" and "moveend" events. For catching those two, you don't need to call map.on twice: events can be joined in one string:

map.on('load moveend', function(e) { ... });

Upvotes: 6

Related Questions