# Class PermalinkService

#### Hierarchy

- PermalinkService

- Defined in src/permalink/Permalink.js:288

#####
Index

### Constructors

constructor

### Properties

$timeout_
crosshairEnabledByDefault_
crosshairFeature_
crosshairStyle_
defaultTheme_
featureHashFormat_
featureHelper_
featureOverlay_
gmfDataSourcesManager_
gmfExternalDataSourcesManager_
gmfLayerBeingSwipe_
gmfObjectEditingManager_
gmfThemeManager_
gmfThemes_
gmfTreeManager_
gmfUser
listenerKeys_
mapTooltip_
mapViewPropertyChangeEventKey_
map_
ngeoAutoProjection_
ngeoBackgroundLayerMgr_
ngeoDebounce_
ngeoEventHelper_
ngeoFeatures_
ngeoLocation_
ngeoQuerent_
ngeoStateManager_
ngeoWMSTime_
ngeoWfsPermalink_
pointRecenterZoom_
q_
rootScope_
setExternalDataSourcesStatePromise_
sourceProjections_

### Methods

addNgeoFeature_
cleanParams
containsLayerName
createFilterGroup_
defaultThemeName
defaultThemeNameFromFunctionalities
getBackgroundLayer
getBackgroundLayerOpacity
getFeatures
getMapCenter
getMapCrosshair
getMapTooltip
getMapZoom
getWfsPermalinkData_
handleBackgroundLayerManagerChange_
handleExternalDSGroupCollectionAdd_
handleExternalDSGroupCollectionRemove_
handleLayerBeingSwipeChange_
handleMapSwipeValue_
handleNgeoFeaturesAdd_
handleNgeoFeaturesChange_
handleNgeoFeaturesRemove_
initExternalDataSources_
initLayers_
refreshFirstLevelGroups
refreshLayerTime
registerExternalDSGroup_
registerMap_
removeNgeoFeature_
setDimensions
setExternalDataSourcesState_
setMap
setMapCrosshair
setMapTooltip
setNodeTime_
setThemeInUrl_
themeInUrl_
unregisterExternalDSGroup_
unregisterMap_

## Constructors

### constructor

- new PermalinkService($q: IQService, $timeout: ITimeoutService, $rootScope: IScope, $injector: IInjectorService, ngeoDebounce: miscDebounce<(() => void)>, gettextCatalog: gettextCatalog, ngeoEventHelper: EventHelper, ngeoStateManager: StatemanagerService, ngeoLocation: StatemanagerLocation, gmfLayerBeingSwipe: any, gmfPermalinkOptions: any, gmfDataSourcesManager: any, ngeoWMSTime: WMSTime): PermalinkService

- The Permalink service for GMF, which uses the `ngeo.statemanager.Service` to manage the GMF application state. Here's the list of states are are managed:

  - the map center and zoom level
  - the current background layer selected
  - whether to add a crosshair feature in the map or not
  - the dimensions value

  For time layers the time range or time value is added

  It can also be used to add different types of things in the map, such as features, external data sources, etc.

  This is made using parameters in the url, which can be static (i.e. parameters that always have the same name) or dynamic (i.e. parameters that have a static prefix but with a full name being dynamic).

  Here's a complete list of possible parameters and what they do. But first, a legend

  === Parameters [type] ===

  - `[paramameter_name]` (type) [parameter documentation]

  === Parameters (static) ===

  A static parameter always have the same name.

  - `baselayer_ref` - "string" The name of the base layer that should be set visible as default in the map. If none is set, then the default one in the loaded theme is set instead.

  - `eds_n` (string), `eds_u` (string) These parameters stand for:

    - eds_n: "External Data Sources Names"
    - eds_u: "External Data Sources URLs" These parameters define external WMS/WMTS data sources to add to the map upon initialization. Both values are comma-separated lists, `eds_u` containing the urls to the services and `eds_n` the layer names (separated by `;`). Here's an example: &eds_n=a;b;c,d,e&eds_u=host1.com,host2.com,host3.com, which reads as:
    - host1.com - layers: a, b and c
    - host2.com - layers: d
    - host3.com - layers: e For these parameters to work properly, they must define the same number of elements, i.e. same number of names and urls.

  - `map_crosshair` (boolean) If this parameter set to `true`, then a crosshair marker will be added to the center of the map upon initialization. The marker will stay at this location.

  - `map_tooltip` (string) If set, then the text defined in this parameter will be added as a tooltip at center of the map upon initialization.

  - `map_x` (number), `map_y` (number) These two parameters define a coordinate the map view should be centered to upon initialization. The value must be in the map view projection.

  - `map_zoom` (number) Defines the zoom level the map view should be zoomed to upon initialization.

  - `rl_features` (string) This parameter defines vector features to add to the map upon initialization. In addition, if the application includes the draw tool, the features added can be modified. The draw tool can also be used to add new features, which are automatically added in the url.

  - `tree_groups` (string) Defines the layer groups that should be added to the layer tree upon application initialization as a comma-separated list. For example: Layers,Filters,Externals

  - `wfs_layer` (string) If set, this parameter defines the name of a layer that supports WFS to use to fetch features and add them to the map upon initialization. The dynamic parameter `wfs_[]` is required to identify the features to fetch.

  - `wfs_ngroups` (number) If set, then `wfs_layer` represents the name of a group and this property defines how many layers are in it. Requires `wfs_layer` to be set.

  - `wfs_show_features` (boolean) If set to `false` or `0`, then the features returned by the `wfs_layer` parameter will not be shown in the map.

  === Parameters (dynamic) ===

  Dynamic parameters have variable names, which is always composed of:

  - a static prefix
  - a variable suffix

  The same dynamic parameter can be set multiple times, with different suffix values as name.

  For example: `&wfs_a=&wfs_b=`.

  - `wfs_` is the static prefix

  - the name used as reference for this dynamic parameter is `wfs_[]`

  - therefore, this example has 2 `wfs_[]` parameters set, with `a` and `b` being the variable suffix

  - `dim_[]` (string) Variable suffix: the name of a dimension Value: * Defines the value of a specific dimension to set upon loading the application. For example: `&dim_time=2019-01-25T14:45:51.986Z`. WMS data sources that support the dimension set will be initialized with its value.

  - `tree_enable_[]` (boolean) Variable suffix: the name of a layer group Value: whether the group should be enabled or not in the layer tree For example: `&tree_enable_polygon=true&tree_enable_point=false` means that the group `polygon` will be enabled in the layer tree, but not `point`.

  - `tree_group_layers_[]` (string) Variable suffix: the name of a layer group Value: a comma-separated list of layers within the group that should be enabled upon initialization. For example: `&tree_group_layers_polygon=forest,lake` means that only the layers `forest` and `lake` within the group `polygon` would be enabled upon initialization.

  - `tree_opacity_[]` (number) Variable suffix: the name of a layer group Value: Number between 0 (transparent) and 1 (opaque) Defines the opacity of a layer group upon initialization.

  - `tree_time_[]` (date) Variable suffix: the name of a layer group or layer Value: a date or date interval with the resolution of the time of the layer or group Defines the time or time interval for a time layer or a group.

  - `wfs_[]` (string) Variable suffix: the name of an attribute Value: A comma-separated list of values for the attribute This parameter requires `wfs_layer` in order to work properly. If set, it defines the filters to build to fetch the features to add to the map. For example: `&wfs_layer=fuel&wfs_osm_id=1420918679,441134960` the layer `fuel` will be fetched features with the attribute `osm_id` equal to `1420918679` or `441134960`. If `wfs_ngroups` is set, then an index is added to after the prefix of the `wfs_[]` parameter, for example: `wfs_ngroups=2&wfs_0_[]=&wfs_1_[]=`

  === More documentation ===

  To have the whole possibilities offer by the permalink, these services should be instantiated: ngeoBackgroundLayerMgr, ngeoFeatureOverlayMgr, ngeoFeatureHelper, gmfPermalinkOptions, gmfThemes, gmfObjectEditingManager, gmfThemeManager, defaultTheme, gmfTreeManager, ngeoWfsPermalink, ngeoAutoProjection and ngeoFeatures.

  Used functionalities:

  - `default_theme`: Theme to use by default.

  ### Ng Inject

  ### Ngdoc

  service

  ### Ngname

  gmfPermalink

  #### Parameters

  - ##### $q: IQService

    The Angular $q service.

  - ##### $timeout: ITimeoutService

    Angular timeout service.

  - ##### $rootScope: IScope

    Angular rootScope.

  - ##### $injector: IInjectorService

    Main injector.

  - ##### ngeoDebounce: miscDebounce<(() => void)>

    ngeo Debounce factory.

  - ##### gettextCatalog: gettextCatalog

    Gettext service.

  - ##### ngeoEventHelper: EventHelper

    Ngeo event helper service

  - ##### ngeoStateManager: StatemanagerService

    The ngeo statemanager service.

  - ##### ngeoLocation: StatemanagerLocation

    ngeo location service.

  - ##### gmfLayerBeingSwipe: any

  - ##### gmfPermalinkOptions: any

    The options.

  - ##### gmfDataSourcesManager: any

    The gmf datasourcemanager service.

  - ##### ngeoWMSTime: WMSTime

    The ngeo wmstime service

  #### Returns PermalinkService

  - Defined in src/permalink/Permalink.js:288

## Properties

### $timeout_

$timeout_: ITimeoutService

- Defined in src/permalink/Permalink.js:316

### crosshairEnabledByDefault_

crosshairEnabledByDefault_: boolean

- Defined in src/permalink/Permalink.js:394

### crosshairFeature_

crosshairFeature_: Feature<Geometry>

- Defined in src/permalink/Permalink.js:486
- Defined in src/permalink/Permalink.js:809

### crosshairStyle_

crosshairStyle_: StyleLike

- Defined in src/permalink/Permalink.js:491

### defaultTheme_

defaultTheme_: string

- Defined in src/permalink/Permalink.js:428

### featureHashFormat_

featureHashFormat_: default

- Defined in src/permalink/Permalink.js:501

### featureHelper_

featureHelper_: FeatureHelper

- Defined in src/permalink/Permalink.js:379

### featureOverlay_

featureOverlay_: FeatureOverlay

- Defined in src/permalink/Permalink.js:374

### gmfDataSourcesManager_

gmfDataSourcesManager_: any

- Defined in src/permalink/Permalink.js:347

### gmfExternalDataSourcesManager_

gmfExternalDataSourcesManager_: any

- Defined in src/permalink/Permalink.js:404

### gmfLayerBeingSwipe_

gmfLayerBeingSwipe_: any

- Defined in src/permalink/Permalink.js:369

### gmfObjectEditingManager_

gmfObjectEditingManager_: any

- Defined in src/permalink/Permalink.js:416

### gmfThemeManager_

gmfThemeManager_: any

- Defined in src/permalink/Permalink.js:423

### gmfThemes_

gmfThemes_: any

- Defined in src/permalink/Permalink.js:411

### gmfTreeManager_

gmfTreeManager_: any

- Defined in src/permalink/Permalink.js:433

### gmfUser

gmfUser: any

- Defined in src/permalink/Permalink.js:450
- Defined in src/permalink/Permalink.js:452

### listenerKeys_

listenerKeys_: EventsKey[]

- Defined in src/permalink/Permalink.js:468

### mapTooltip_

mapTooltip_: default

- Defined in src/permalink/Permalink.js:496
- Defined in src/permalink/Permalink.js:862

### mapViewPropertyChangeEventKey_

mapViewPropertyChangeEventKey_: EventsKey

The key for map view 'propertychange' event.

- Defined in src/permalink/Permalink.js:325
- Defined in src/permalink/Permalink.js:993
- Defined in src/permalink/Permalink.js:1043

### map_

map_: Map

- Defined in src/permalink/Permalink.js:458
- Defined in src/permalink/Permalink.js:930
- Defined in src/permalink/Permalink.js:934

### ngeoAutoProjection_

ngeoAutoProjection_: AutoProjectionService

- Defined in src/permalink/Permalink.js:463

### ngeoBackgroundLayerMgr_

ngeoBackgroundLayerMgr_: MapBackgroundLayerManager

- Defined in src/permalink/Permalink.js:362

### ngeoDebounce_

ngeoDebounce_: miscDebounce<(() => void)>

- Defined in src/permalink/Permalink.js:332

### ngeoEventHelper_

ngeoEventHelper_: EventHelper

- Defined in src/permalink/Permalink.js:337

### ngeoFeatures_

ngeoFeatures_: Collection<Feature<Geometry>>

- Defined in src/permalink/Permalink.js:357

### ngeoLocation_

ngeoLocation_: StatemanagerLocation

- Defined in src/permalink/Permalink.js:440

### ngeoQuerent_

ngeoQuerent_: Querent

- Defined in src/permalink/Permalink.js:384

### ngeoStateManager_

ngeoStateManager_: StatemanagerService

- Defined in src/permalink/Permalink.js:342

### ngeoWMSTime_

ngeoWMSTime_: WMSTime

- Defined in src/permalink/Permalink.js:352

### ngeoWfsPermalink_

ngeoWfsPermalink_: WfsPermalinkService

- Defined in src/permalink/Permalink.js:445

### pointRecenterZoom_

pointRecenterZoom_: number

- Defined in src/permalink/Permalink.js:399

### q_

q_: IQService

- Defined in src/permalink/Permalink.js:306

### rootScope_

rootScope_: IScope

- Defined in src/permalink/Permalink.js:311

### setExternalDataSourcesStatePromise_

setExternalDataSourcesStatePromise_: IPromise<void>

- Defined in src/permalink/Permalink.js:635
- Defined in src/permalink/Permalink.js:1798
- Defined in src/permalink/Permalink.js:1849

### sourceProjections_

sourceProjections_: Projection[]

A list of projections that the coordinates in the permalink can be in.

- Defined in src/permalink/Permalink.js:475
- Defined in src/permalink/Permalink.js:479

## Methods

### addNgeoFeature_

- addNgeoFeature_(feature: Feature<Geometry>): void

- Listen to any changes that may occur within the feature in order to update the state of the permalink accordingly.

  #### Parameters

  - ##### feature: Feature<Geometry>

    Feature.

  #### Returns void

  - Defined in src/permalink/Permalink.js:1455

### cleanParams

- cleanParams(groups: any[]): void

- Clean the permalink parameters

  #### Parameters

  - ##### groups: any[]

    firstlevel groups of the tree

  #### Returns void

  - Defined in src/permalink/Permalink.js:1858

### containsLayerName

- containsLayerName(layer: BaseLayer, name: string): boolean

- Contains the layer name

  ### Returns

  The containing status

  #### Parameters

  - ##### layer: BaseLayer

    The layer to inspect

  - ##### name: string

    The layer name to find

  #### Returns boolean

  - Defined in src/permalink/Permalink.js:1753

### createFilterGroup_

- createFilterGroup_(prefix: string, paramKeys: string[]): WfsPermalinkFilterGroup

- Create a filter group for a given prefix from the query params.

  ### Returns

  A filter group.

  #### Parameters

  - ##### prefix: string

    E.g. `wfs_` or `wfs_0_`.

  - ##### paramKeys: string[]

    All param keys starting with `wfs_`.

  #### Returns WfsPermalinkFilterGroup

  - Defined in src/permalink/Permalink.js:1550

### defaultThemeName

- defaultThemeName(): string

- Get the default theme from url, local storage, user functionalities or defaultTheme constant.

  ### Returns

  default theme name.

  #### Returns string

  - Defined in src/permalink/Permalink.js:1215

### defaultThemeNameFromFunctionalities

- defaultThemeNameFromFunctionalities(): string

- Get the default theme from user functionalities.

  ### Returns

  default theme name.

  #### Returns string

  - Defined in src/permalink/Permalink.js:1250

### getBackgroundLayer

- getBackgroundLayer(layers: BaseLayer[]): BaseLayer

- Get the background layer object to use to initialize the map from the state manager.

  ### Returns

  Background layer.

  #### Parameters

  - ##### layers: BaseLayer[]

    Array of background layer objects.

  #### Returns BaseLayer

  - Defined in src/permalink/Permalink.js:1054

### getBackgroundLayerOpacity

- getBackgroundLayerOpacity(): number

- Get the background layer opacity to use to initialize the map from the state manager.

  ### Returns

  Opacity.

  #### Returns number

  - Defined in src/permalink/Permalink.js:1071

### getFeatures

- getFeatures(): Feature<Geometry>[]

- Get the ngeo features from the state manager for initialization purpose

  ### Returns

  The features read from the state manager.

  #### Returns Feature<Geometry>[]

  - Defined in src/permalink/Permalink.js:877

### getMapCenter

- getMapCenter(): Coordinate

- Get the coordinate to use to initialize the map view from the state manager.

  ### Returns

  The coordinate for the map view center.

  #### Returns Coordinate

  - Defined in src/permalink/Permalink.js:733

### getMapCrosshair

- getMapCrosshair(): boolean

- Get the map crosshair property from the state manager, if defined.

  ### Returns

  Whether map crosshair property is set or not.

  #### Returns boolean

  - Defined in src/permalink/Permalink.js:776

### getMapTooltip

- getMapTooltip(): string

- Get the tooltip text from the state manager.

  ### Returns

  Tooltip text.

  #### Returns string

  - Defined in src/permalink/Permalink.js:823

### getMapZoom

- getMapZoom(): number

- Get the zoom level to use to initialize the map view from the state manager.

  ### Returns

  The zoom for the map view.

  #### Returns number

  - Defined in src/permalink/Permalink.js:764

### getWfsPermalinkData_

- getWfsPermalinkData_(): WfsPermalinkData

- Get the query data for a WFS permalink.

  ### Returns

  The query data.

  #### Returns WfsPermalinkData

  - Defined in src/permalink/Permalink.js:1501

### handleBackgroundLayerManagerChange_

- handleBackgroundLayerManagerChange_(): void

- Called when the background layer changes. Update the state using the background layer label, i.e. its name.

  #### Returns void

  - Defined in src/permalink/Permalink.js:1080

### handleExternalDSGroupCollectionAdd_

- handleExternalDSGroupCollectionAdd_(evt: Event | BaseEvent): void

- #### Parameters

  - ##### evt: Event | BaseEvent

    Collection event.

  #### Returns void

  - Defined in src/permalink/Permalink.js:1725

### handleExternalDSGroupCollectionRemove_

- handleExternalDSGroupCollectionRemove_(evt: Event | BaseEvent): void

- #### Parameters

  - ##### evt: Event | BaseEvent

    Collection event.

  #### Returns void

  - Defined in src/permalink/Permalink.js:1772

### handleLayerBeingSwipeChange_

- handleLayerBeingSwipeChange_(layer: LayerGroup | Layer<Source, LayerRenderer<any>>, oldLayer: LayerGroup | Layer<Source, LayerRenderer<any>>): void

- Called when layer being swipe

  #### Parameters

  - ##### layer: LayerGroup | Layer<Source, LayerRenderer<any>>

    layer object.

  - ##### oldLayer: LayerGroup | Layer<Source, LayerRenderer<any>>

    old layer object.

  #### Returns void

  - Defined in src/permalink/Permalink.js:692

### handleMapSwipeValue_

- handleMapSwipeValue_(): void

- Called when map swipe value change.

  #### Returns void

  - Defined in src/permalink/Permalink.js:716

### handleNgeoFeaturesAdd_

- handleNgeoFeaturesAdd_(event: Event | BaseEvent): void

- #### Parameters

  - ##### event: Event | BaseEvent

    Collection event.

  #### Returns void

  - Defined in src/permalink/Permalink.js:1426

### handleNgeoFeaturesChange_

- handleNgeoFeaturesChange_(): void

- Called once upon initialization of the permalink service if there's at least one feature in the ngeoFeatures collection, then called every time the collection changes or any of the features within the collection changes.

  #### Returns void

  - Defined in src/permalink/Permalink.js:1479

### handleNgeoFeaturesRemove_

- handleNgeoFeaturesRemove_(event: Event | BaseEvent): void

- #### Parameters

  - ##### event: Event | BaseEvent

    Collection event.

  #### Returns void

  - Defined in src/permalink/Permalink.js:1439

### initExternalDataSources_

- initExternalDataSources_(): IPromise<void>

- ### Returns

  Promise

  #### Returns IPromise<void>

  - Defined in src/permalink/Permalink.js:1587

### initLayers_

- initLayers_(): void

- #### Returns void

  - Defined in src/permalink/Permalink.js:1265

### refreshFirstLevelGroups

- refreshFirstLevelGroups(): void

- Get the current first level node names in the tree manager and update the correspondent state of the permalink.

  #### Returns void

  - Defined in src/permalink/Permalink.js:1134

### refreshLayerTime

- refreshLayerTime(treeCtrl: LayertreeController, time: TimeRange): void

- Update the time values in the state.

  #### Parameters

  - ##### treeCtrl: LayertreeController

    Controller.

  - ##### time: TimeRange

    The start and optionally the end datetime (for time range selection) selected by user

  #### Returns void

  - Defined in src/permalink/Permalink.js:1160

### registerExternalDSGroup_

- registerExternalDSGroup_(group: Group): void

- #### Parameters

  - ##### group: Group

    Data source group.

  #### Returns void

  - Defined in src/permalink/Permalink.js:1739

### registerMap_

- registerMap_(map: Map, oeFeature: Feature<Geometry>): void

- Listen to the map view property change and update the state accordingly.

  #### Parameters

  - ##### map: Map

    The ol3 map object.

  - ##### oeFeature: Feature<Geometry>

    ObjectEditing feature

  #### Returns void

  - Defined in src/permalink/Permalink.js:951

### removeNgeoFeature_

- removeNgeoFeature_(feature: Feature<Geometry>): void

- Unregister any event listener from the feature.

  #### Parameters

  - ##### feature: Feature<Geometry>

    Feature.

  #### Returns void

  - Defined in src/permalink/Permalink.js:1468

### setDimensions

- setDimensions(dimensions: Object): void

- #### Parameters

  - ##### dimensions: Object

    The global dimensions object.

  #### Returns void

  - Defined in src/permalink/Permalink.js:890

### setExternalDataSourcesState_

- setExternalDataSourcesState_(): void

- Set the External Data Sources parameters in the url.

  #### Returns void

  - Defined in src/permalink/Permalink.js:1793

### setMap

- setMap(map: Map): void

- Bind an ol3 map object to this service. The service will, from there on, listen to the properties changed within the map view and update the following state properties: map_x, map_y and map_zoom.

  If the service is already bound to a map, those events are unlistened first.

  #### Parameters

  - ##### map: Map

    The ol3 map object.

  #### Returns void

  - Defined in src/permalink/Permalink.js:923

### setMapCrosshair

- setMapCrosshair(opt_center?: Coordinate): void

- Sets the map crosshair to the center (or the map center if nothing provided). Overwrites an existing map crosshair.

  #### Parameters

  - ##### `Optional` opt_center: Coordinate

    Optional center coordinate.

  #### Returns void

  - Defined in src/permalink/Permalink.js:787

### setMapTooltip

- setMapTooltip(tooltipText: string, opt_center?: Coordinate): void

- Sets the map tooltip to the center (or the map center if nothing provided). Overwrites an existing map tooltip.

  #### Parameters

  - ##### tooltipText: string

    Text to display in tooltip.

  - ##### `Optional` opt_center: Coordinate

    Optional center coordinate.

  #### Returns void

  - Defined in src/permalink/Permalink.js:834

### setNodeTime_

- setNodeTime_(treeCtrl: LayertreeController): void

- Set the time from permalink in datasource and widget.

  #### Parameters

  - ##### treeCtrl: LayertreeController

    Controller

  #### Returns void

  - Defined in src/permalink/Permalink.js:1910

### setThemeInUrl_

- setThemeInUrl_(themeName: string): void

- #### Parameters

  - ##### themeName: string

    Theme name.

  #### Returns void

  - Defined in src/permalink/Permalink.js:1186

### themeInUrl_

- themeInUrl_(pathElements: string[]): boolean

- Return true if there is a theme specified in the URL path.

  ### Returns

  theme in path.

  #### Parameters

  - ##### pathElements: string[]

    Array of path elements.

  #### Returns boolean

  - Defined in src/permalink/Permalink.js:1178

### unregisterExternalDSGroup_

- unregisterExternalDSGroup_(group: Group): void

- #### Parameters

  - ##### group: Group

    Data source group.

  #### Returns void

  - Defined in src/permalink/Permalink.js:1786

### unregisterMap_

- unregisterMap_(): void

- Remove any event listeners from the current map.

  #### Returns void

  - Defined in src/permalink/Permalink.js:1038

Generated using TypeDoc