How to get bounds after MapboxGeocoder flyto event?

Viewed 724

Looks like if I call map.getBounds inside geocoder I always get the previous results. Is there a callback or something to get the bounds after geocode flies to the destinations. Here is my code:

var geocoder = new MapboxGeocoder({accessToken: mapboxgl.accessToken});
geocoder.on('result', function(ev) {

        console.log("CENTER:",ev.result.center);
        console.log("BOUNDS:",map.getBounds());
        //loadByBounds(map.getBounds());
    });
1 Answers
Related