@terrestris/ol-util
Version:
A set of helper classes for working with openLayers
76 lines (75 loc) • 2.49 kB
TypeScript
import OlFeature from 'ol/Feature';
import OlGeomPoint from 'ol/geom/Point';
import OlLayerVector from 'ol/layer/Vector';
import OlMap, { MapOptions } from 'ol/Map';
import OlSourceVector from 'ol/source/Vector';
/**
* A set of some useful static helper methods.
*
* @class
*/
export declare class TestUtil {
static mapDivId: string;
static mapDivHeight: number;
static mapDivWidth: number;
/**
* Creates and applies a map <div> element to the body.
*
* @return {HTMLElement} The mounted <div> element.
*/
static mountMapDiv: () => HTMLDivElement;
/**
* Removes the map div element from the body.
*/
static unmountMapDiv: () => void;
/**
* Creates an OpenLayers map.
*
* @param {MapOptions & { resolutions: number[] }} mapOpts Additional options for the map to create.
* @return {OlMap} The ol map.
*/
static createMap: (mapOpts?: MapOptions & {
resolutions: number[];
}) => OlMap;
/**
* Removes the map.
*
* @param {OlMap} map
*/
static removeMap: (map: OlMap) => void;
/**
* Simulates a browser pointer event on the map viewport.
* Origin: https://github.com/openlayers/openlayers/blob/master/test/spec/ol/interaction/draw.test.js#L67
*
* @param {OlMap} map The map to use.
* @param {string} type Event type.
* @param {number} x Horizontal offset from map center.
* @param {number} y Vertical offset from map center.
* @param {boolean} shift Shift key is pressed
* @param {boolean} dragging Whether the map is being dragged or not.
*/
static simulatePointerEvent: (map: OlMap, type: string, x: number, y: number, shift: boolean, dragging: boolean) => void;
/**
* Creates and returns an empty vector layer.
*
* @param {Object} properties The properties to set.
* @return {OlLayerVector<OlSourceVector>} The layer.
*/
static createVectorLayer: (properties?: Record<string, any>) => OlLayerVector<OlSourceVector<OlFeature<import("ol/geom").Geometry, {
[x: string]: any;
}>>, OlFeature<import("ol/geom").Geometry, {
[x: string]: any;
}>>;
/**
* Returns a point feature with a random position.
* @type {Object}
*/
static generatePointFeature: (props?: {
ATTR_1: number;
ATTR_2: string;
ATTR_3: string;
}) => OlFeature<OlGeomPoint, {
[x: string]: any;
}>;
}
export default TestUtil;