0

I am trying to capture the extent of my Map on 'moveend' and it seems that the extent that is being captured is zoomed out quite a bit...

idle(event) {
function onMoveEnd(evt) {
const mapChange = map.getView().calculateExtent(map.getSize());
}
MapValues.map.on('moveend', onMoveEnd);
}

I believe this is pretty much what I have seen as examples but it doesn't save the true zoomed extent on moveend.

Any help (especially the right solution :) ) is appreciated!

Funn_Bobby
  • 647
  • 1
  • 20
  • 57
  • Are you expecting true distance on the ground? You may need to adjust for point resolution https://openlayers.org/en/latest/apidoc/module-ol_proj.html#.getPointResolution (e.g. Greenland may look as big as Africa on your map but it is not). – Mike Mar 04 '20 at 16:08
  • I'm not sure...but I don't think so. I have an extent at the end of panning or zooming using the code above...but if I reload that extent it is not what I was previously looking at...it is zoomed out? – Funn_Bobby Mar 04 '20 at 16:45
  • That will happen in versions 3, 4 and 5 (not 6) Unless you specify `constrainResolution: false` in the options it goes to an integer zoom level https://openlayers.org/en/v5.3.0/apidoc/module-ol_View-View.html#fit – Mike Mar 04 '20 at 17:51

1 Answers1

0

Okay, what worked for me was adding this line after "calculateExtent"

 map.view.setResolution(map.view.getResolution() * 0.5);
Funn_Bobby
  • 647
  • 1
  • 20
  • 57