Using OL 6.5.0, the following snippet produces a map where the feature goes outside of the bounds of the map, rather than being completely contained (with a 20px margin) within the bounds of the map.
const extent = layer.getSource().getExtent();
view.fit(extent, {
size: map.getSize(),
padding: [20, 20, 20, 20],
});
I tried setting nearest to true / false but the result is the same.
Result (ignore the fuzz):
I expect the entire feature to be within the border of the map, but it is not. Am I missing something?
Expected (or close to it -- again, ignore the fuzz):
Here's how I'm instantiating the map:
const map = this.map = maps[mapTargetId] = new ol.Map({
target: mapTargetId,
overlays: [overlay],
layers: await this.getBaseLayers(),
view: new ol.View({
projection,
center: [0, 0],
zoomFactor: 2,
zoom: defaultZoom,
minZoom: 1,
maxZoom: 12,
})
});