如何在 MapboxGeocoder flyto 事件后获得边界?

How to get bounds after MapboxGeocoder flyto event?

看起来如果我在地理编码器中调用 map.getBounds,我总是会得到以前的结果。 在地理编码飞到目的地后是否有回调或其他东西来获取边界。这是我的代码:

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());
    });

也许您可以通过应用事件侦听器来对 mooveend 事件作出反应。

"Mooveend: Fired just after the map completes a transition from one view to another, as the result of either user interaction or methods such as Map#jumpTo."

https://www.mapbox.com/mapbox-gl-js/api/#map.event:moveend