Creating a navigation history
In the next example, called ch06_navhist
, we will create a fully functional navigation history. First, as usual, we have to make some considerations. We will store an array in the control containing the view properties for every change. We will also store the current index as we must remember to step our control between view states. A not-so-important property that we will store is a Boolean value, representing whether we should record the new view or not. This is particularly handy when we step between the history
elements and do not want to double store these states. First, we create the first button for the control:
ol.control.NavigationHistory = function (opt_options) { var options = opt_options || {}; var _this = this; var controlDiv = document.createElement('div'); controlDiv.className = options.class || 'ol-unselectable ol-control'; var backButton = document.createElement('button'); backButton.className = 'ol-navhist-back'; ...