* Allow user to move back in history
()
| 1152 | * Allow user to move back in history |
| 1153 | */ |
| 1154 | back() { |
| 1155 | let history = this._history; |
| 1156 | let curr = history[this._historyIndex]; |
| 1157 | |
| 1158 | if (this._historyIndex > 0) { |
| 1159 | this._map.contextMenu.toggleContextMenuItem('Forward', 'enabled'); // forward contextmenu item |
| 1160 | this._historyIndex--; |
| 1161 | let prev = history[this._historyIndex]; |
| 1162 | // Disable back, reload contextmenu item when at the end of history |
| 1163 | if (this._historyIndex === 0) { |
| 1164 | this._map.contextMenu.toggleContextMenuItem('Back', 'disabled'); // back contextmenu item |
| 1165 | this._map.contextMenu.toggleContextMenuItem('Reload', 'disabled'); // reload contextmenu item |
| 1166 | this._reloadButton?.disable(); |
| 1167 | } |
| 1168 | |
| 1169 | if (prev.zoom !== curr.zoom) { |
| 1170 | this._traversalCall = 2; // allows the next 2 moveends to be ignored from history |
| 1171 | |
| 1172 | let currScale = this._map.options.crs.scale(curr.zoom); // gets the scale of the current zoom level |
| 1173 | let prevScale = this._map.options.crs.scale(prev.zoom); // gets the scale of the previous zoom level |
| 1174 | |
| 1175 | let scale = currScale / prevScale; // used to convert the previous pixel location to be in terms of the current zoom level |
| 1176 | |
| 1177 | this._map.panBy([prev.x * scale - curr.x, prev.y * scale - curr.y], { |
| 1178 | animate: false |
| 1179 | }); |
| 1180 | this._map.setZoom(prev.zoom); |
| 1181 | } else { |
| 1182 | this._traversalCall = 1; |
| 1183 | this._map.panBy([prev.x - curr.x, prev.y - curr.y]); |
| 1184 | } |
| 1185 | } |
| 1186 | } |
| 1187 | |
| 1188 | /** |
| 1189 | * Allows user to move forward in history |
no outgoing calls
no test coverage detected