MCPcopy Index your code
hub / github.com/Maps4HTML/MapML.js / forward

Method forward

src/mapml-viewer.js:1148–1179  ·  view source on GitHub ↗

* Allows user to move forward in history

()

Source from the content-addressed store, hash-verified

1146 * Allows user to move forward in history
1147 */
1148 forward() {
1149 let history = this._history;
1150 let curr = history[this._historyIndex];
1151 if (this._historyIndex < history.length - 1) {
1152 this._map.contextMenu.toggleContextMenuItem('Back', 'enabled'); // back contextmenu item
1153 this._map.contextMenu.toggleContextMenuItem('Reload', 'enabled'); // reload contextmenu item
1154 this._reloadButton?.enable();
1155 this._historyIndex++;
1156 let next = history[this._historyIndex];
1157 // disable forward contextmenu item, when at the end of forward history
1158 if (this._historyIndex + 1 === this._history.length) {
1159 this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item
1160 }
1161
1162 if (next.zoom !== curr.zoom) {
1163 this._traversalCall = 2; // allows the next 2 moveends to be ignored from history
1164
1165 let currScale = this._map.options.crs.scale(curr.zoom); // gets the scale of the current zoom level
1166 let nextScale = this._map.options.crs.scale(next.zoom); // gets the scale of the next zoom level
1167
1168 let scale = currScale / nextScale; // used to convert the next pixel location to be in terms of the current zoom level
1169
1170 this._map.panBy([next.x * scale - curr.x, next.y * scale - curr.y], {
1171 animate: false
1172 });
1173 this._map.setZoom(next.zoom);
1174 } else {
1175 this._traversalCall = 1;
1176 this._map.panBy([next.x - curr.x, next.y - curr.y]);
1177 }
1178 }
1179 }
1180
1181 /**
1182 * Allows the user to reload/reset the map's location to it's initial location

Callers 1

_setUpEventsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected