Reputation:
I'm creating a 'bookmarking' feature on my map, recording the extent of the current view via ol.View.calculateExtent()
. Once I've grabbed this extent I persist it (no loss of precision, in 'EPSG:900913').
Problem now is if I feed this extent into ol.View.fitExtent()
I don't get exactly the same view, I get a slightly 'zoomed out' one.
The coordinates are exactly the same, the map size (ol.Map.getSize()
) even the resolution (ol.View().getResolution()
) but each time my recorded 'view' when I call it is further out than the recorded one.
Any ideas how I can exactly record the current 'view' and replay it accurately?Is this rounding? Should I not be using fitExtent?
N.B. This doesn't ALWAYS' happen! At high zooms it can sometimes accurately record and return me to the same view - resolutions at 2.388657133911758, 1.194328566955879 and 305.748113140705, when recorded, do not seem to exhibit this behaviour.
Upvotes: 1
Views: 91
Reputation: 17049
It has been replaced by ol.View.fit
in v3.7.0:
Replace ol.View.fitExtent() and ol.View.fitGeometry() with ol.View.fit() ... This combines two previously distinct functions into one more flexible call which takes either a geometry or an extent.
Upvotes: 0