ViewHistory

ol-ishare/history~ ViewHistory

Object for remembering and recalling previous map views

Constructor

new ViewHistory(map, optionsopt)

Parameters:
Name Type Attributes Description
map ol/Map~Map

The OpenLayers map for which to track view history

options Object <optional>

History options

Properties
Name Type Attributes Default Description
granularity Number <optional>
250

Minimum time to wait between map view changes before adding them to the history

Methods

getSize() → {Number}

Returns:

The number of entries in the history

Type
Number

getPosition() → {Number}

Returns:

The current position in the history

Type
Number

setPosition(position)

Parameters:
Name Type Description
position Number

Sets the view to the one from the specified position in the history. Values below or above the bounds of the history will set the map to either the first or last entry, respectively

getEntry(positionopt) → {module:ol-ishare/history~Entry}

Parameters:
Name Type Attributes Default Description
position Number <optional>
this.getPosition()

Fetches the entry from the specified position in the history. Values below or above the bounds of the history will return either the first or last entry, respectively If no value is passed, returns the current entry

Returns:

View history entry object

Type
module:ol-ishare/history~Entry

setView(entry)

Updates the map to the view with the specified centre and resolution, creating a new history entry in the process

Parameters:
Name Type Description
entry module:ol-ishare/history~Entry

A history entry object

back(stepsopt)

Sets map view to that at steps changes ago.

Parameters:
Name Type Attributes Default Description
steps Number <optional>
1

The number of entries in the history to move back. If this is greater than the number of entires prior to the current point in the map's history, the map will be set to the first entry (normally the map's initial view).

forward(stepsopt)

Sets map view to that at steps changes after the current one in the history.

Parameters:
Name Type Attributes Default Description
steps Number <optional>
1

The number of entries in the history to move forwards. If this is greater than the number of entires after the current point in the map's history, the map will be set to the last entry.