Sheet Map event equivalent to the Simple event in Google Map

I cannot find a map event in Liflet equal to a Simple event in Google Map.

Definition of the Google Map event "idle" means "This event is fired when the map becomes inactive after panning or zooming."

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

I tried the sheets "viewreset", "load", "blur", "focus", "moveend", but they really differ from the "idle" Google Map.

  • "viewreset": executed only when zooming in / out is complete, and not in the initial and after panning.
  • "load": only during initialization.
  • "moveend": only when panning and zooming, not in initialization.

The best I can do is use this

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

I just want to find out if I am reading the manual incorrectly. Or, even if there is no event equivalent to the Google Play 'idle', is there a better way to implement it?

+4
source share
1 answer

There is no “inactivity” event in the leaflet library, although the description is similar to “moveend” (there is nothing about map initialization).

As you yourself found out, you can use the events "load" and "moveend". To catch these two, you do not need to call twice map.on: events can be combined into one line:

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

Source: https://habr.com/ru/post/1540316/


All Articles