-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Description
Hi,
I often miss a "resize" event on the map container. I know I can create this by listening to window resize and then check if the size of the container div has changed, but it would be better to have this in the Leaflet core. It's especially useful when showing a Leaflet map in a responsive layout with custom layer controls etc.
To get this event with the current Leaflet core, I'm extending the _onResize method of L.Map:
_onResize: function () {
var oldSize = this.getSize(),
newSize = new L.Point(this._container.clientWidth, this._container.clientHeight);
if (!newSize.equals(oldSize)) {
this.fire('resize', newSize);
L.Map.prototype._onResize.call(this)
}
}
Bjorn