OpenLayers 2 had a very useful map.zoomToExtent(extent) feature. Is there something similar in OpenLayers 3? I can get the extent of interest with source
map.zoomToExtent(extent)
source
With OpenLayers 4.x this is still a valid solution:
map.getView().fit(source.getExtent(), map.getSize());
Make sure to set the optional second parameter to prevent console errors, if there are no points on the map.