[GIS] Getting zoom-in previous/next in OpenLayers 3

openlayerszoom

How to get Zoom-in, Zoom-out for previous or next in OpenLayers 3. There are controls for Zoom in or Zoom out for levels and area wise. They are as follows:

    Area zoom:
    var dragzoomin = new ol.interaction.DragZoom({
                condition: ol.events.condition.always
                });
    map.addInteraction(dragzoomin);     

Zoom in for levels

    var view = map.getView();
            view.setZoom(view.getZoom() + 1);

We can get zoom out if it is level wise.
But if it is area wise how to get zoom out and how to store these zoom in and zoom out events for entire session.

Best Answer

You can easily hook it up to the browser's history's buttons. See: http://openlayers.org/en/latest/examples/permalink.html for an example of how to do this.

Related Question