Would be nice to add a callback/then whenever map.fitBounds() ended its operation. Today we have to rely adding map.once('zoomend moveend', function()); to make something happen after.
For example, to make a marker bounce after appearing, i have to:
var marker = getMarker();
map.once('zoomend moveend', ()=>{bounceMarker(marker);});
map.fitBounds(marker.getBounds());
Would be nice to do something like:
map.fitBounds(marker.getBounds()).then(()=>{bounceMarker(marker);});
It would be great if map functions that modifying map state, will return Promise
What i did was, adding method to my map (uses jquery promise, but can be easily replaced):
zoomToBounds: function () {
var promise = $.Deferred();
this.once("moveend", function () {setTimeout(function () {promise.resolve();}, 20);});
this.fitBounds.call(this, arguments);
return promise;
}
Can you replace $.Deferred() with new Promise() And then to create a pull request?
Most helpful comment
It would be great if map functions that modifying map state, will return
Promise