How to zoom map programmatically Openlayers 3?
<p>I want to draw a square around a marker. if I draw a large square the map should zoom out automatically so that we can see the square completely. If I draw a small square the map should zoom in automatically to show the square completely.</p>

<p><a href="https://i.stack.imgur.com/SapoL.jpg" rel="nofollow noreferrer">In this image I have drawn small square so we can see the square completely</a></p>

<p><a href="https://i.stack.imgur.com/Ac85p.jpg" rel="nofollow noreferrer">In this image I have drawn a larger square, Since the map is not zooming out we cannot see the square sides</a></p>