Class: Permalink

ol.control. Permalink

Set an hyperlink that will return the user to the current map view. Just add a permalinkproperty to layers to be handled by the control (and added in the url). The layer's permalink property is used to name the layer in the url. The control must be added after all layer are inserted in the map to take them into acount.


Parameters:
Name Type Argument Description
options Object <optional>
Properties
Name Type Argument Default Description
urlReplace boolean

replace url or not, default true

localStorage boolean | string <optional>
false

save current map view in localStorage, if 'position' only store map position

geohash boolean

use geohash instead of lonlat, default false

fixed integer

number of digit in coords, default 6

anchor boolean

use "#" instead of "?" in href

visible boolean

hide the button on the map, default true

hidden boolean

hide the button on the map, default false DEPRECATED: use visible instead

onclick function

a function called when control is clicked

Extends

Methods


getInitialPosition()

Get the initial position passed by the url


Get layer given a permalink name (permalink propertie in the layer)

Parameters:
Name Type Description
the string

permalink to search for

an Array.<ol.layer> | undefined

array of layer to search in

Returns:
Type
ol.layer | false

Get the permalink

Parameters:
Name Type Argument Default Description
search boolean | string <optional>
false

false: return full link | true: return the search string only | 'position': return position string

Returns:
Type
permalink

getUrlParam(key)

Get a parameter url.

Parameters:
Name Type Description
key string

the key parameter

Returns:

the parameter's value or empty string if not set

Type
string

getUrlParams()

Get the parameters added to the url. The object can be changed to add new values.

Returns:

a key value object added to the url as &key=value

Type
Object

getUrlReplace()

Check if urlreplace is on

Returns:
Type
boolean

hasUrlParam(key)

Has a parameter url.

Parameters:
Name Type Description
key string

the key parameter

Returns:
Type
boolean

setGeohash(b)

Set coordinates as geohash

Parameters:
Name Type Description
b boolean

setMap(map)

Set the map instance the control associated with.

Parameters:
Name Type Description
map ol.Map

The map instance.


setPosition( [force])

Set map position according to the current link

Parameters:
Name Type Argument Default Description
force boolean <optional>
false

if true set the position even if urlReplace is disabled


setUrlParam(key, value)

Set a parameter to the url.

Parameters:
Name Type Description
key string

the key parameter

value string | undefined

the parameter's value, if undefined or empty string remove the parameter


setUrlReplace(replace)

Enable / disable url replacement (replaceSate)

Parameters:
Name Type Description
replace bool