@terrestris/ol-util
Version:
A set of helper classes for working with openLayers
57 lines (56 loc) • 3.13 kB
TypeScript
import OlCollection from 'ol/Collection';
import OlBaseLayer from 'ol/layer/Base';
import OlImageLayer from 'ol/layer/Image';
import OlTileLayer from 'ol/layer/Tile';
import OlMap from 'ol/Map';
/**
* Helper class for some operations related to permalink function.
*
* @class
*/
export declare class PermalinkUtil {
/**
* Creates a permalink based on the given map state. It will contain
* the current view state of the map (center and zoom) as well as
* the current (filtered) list of layers.
*
* @param {OlMap} map The OpenLayers map
* @param {string} separator The separator for the layers list and center
* coordinates in the link. Default is to ';'.
* @param {(layer: OlBaseLayer) => string} identifier Function to generate the identifier of the
* layer in the link. Default is the name
* (given by the associated property) of
* the layer.
* @param {(layer: OlBaseLayer) => boolean} filter Function to filter layers that should be
* added to the link. Default is to add all
* visible layers of type ol/layer/Tile.
* @param {string[]} customAttributes Custom layer attributes which will be saved in the permalink for each layer.
* @return {string} The permalink.
*/
static getLink: (map: OlMap, separator?: string, identifier?: (l: OlBaseLayer) => any, filter?: (l: OlBaseLayer) => boolean, customAttributes?: string[]) => string;
/**
* Applies an existing permalink to the given map.
*
* @param {OlMap} map The OpenLayers map.
* @param {string} separator The separator of the layers list and center
* coordinates in the link. Default is to ';'.
* @param {(layer: OlBaseLayer) => string} identifier Function to generate the identifier of the
* layer in the link. Default is the name
* (given by the associated property) of
* the layer.
* @param {(layer: OlBaseLayer) => boolean} filter Function to filter layers that should be
* handled by the link. Default is to consider all
* current map layers of type ol/layer/Tile.
* @return {string | null} The customLayerAttributes, if defined. Otherwise null.
*/
static applyLink: (map: OlMap, separator?: string, identifier?: (layer: OlBaseLayer) => string, filter?: (layer: OlBaseLayer) => layer is OlTileLayer<any> | OlImageLayer<any>) => string | null;
/**
* Search through the given Ol-Collection for the given id and
* set all parenting groups visible.
* @param {OlMap} map The openlayers map
* @param {OlCollection<OlBaseLayer>} coll The Openlayers Collection
* @param {string} id Ther layer ol uid to search for
*/
static setParentsVisible: (map: OlMap, coll: OlCollection<OlBaseLayer>, id: string) => void;
}
export default PermalinkUtil;