mobility-toolbox-js
Version:
Toolbox for JavaScript applications in the domains of mobility and logistics.
50 lines (49 loc) • 1.76 kB
JavaScript
import { Vector } from 'ol/layer';
import defineDeprecatedProperties from '../utils/defineDeprecatedProperties';
import { deprecated } from './MaplibreLayer';
/**
* @deprecated
*/
class VectorLayer extends Vector {
constructor(options) {
var _a, _b, _c, _d;
if (!options.source && ((_a = options.olLayer) === null || _a === void 0 ? void 0 : _a.getSource())) {
options.source = (_d = (_c = (_b = options.olLayer) === null || _b === void 0 ? void 0 : _b.getSource) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : undefined;
}
super(options);
defineDeprecatedProperties(this, options);
deprecated('Layer is deprecated. Use an OpenLayers Layer instead.');
// Backward compatibility
// @ts-expect-error Property just there for backward compatibility
this.olEventsKeys = [];
}
/**
* @deprecated
*/
clone(newOptions) {
return new VectorLayer(Object.assign(Object.assign({}, this.get('options')), newOptions));
}
/**
* @deprecated
*/
getFeatureInfoAtCoordinate(coordinate) {
let features = [];
const mapInternal = this.getMapInternal();
if (mapInternal) {
const pixel = mapInternal.getPixelFromCoordinate(coordinate);
features =
mapInternal.getFeaturesAtPixel(pixel, {
hitTolerance: this.get('hitTolerance') || 5,
layerFilter: (l) => {
return l === this;
},
}) || [];
}
return Promise.resolve({
coordinate,
features,
layer: this,
});
}
}
export default VectorLayer;