tethys.backend/resources/js/Components/Map/Control.ts
Arno Kaimbacher 4714dfdd94
All checks were successful
CI Pipeline / japa-tests (push) Successful in 46s
- use latest prettier 3.0 with eslint-plugin-prettier: 5.0.0-alpha.2
- npm normal updates
- add all xslt and style asstes in extra folder public/assets2
- linting corrections
- delete local .env.test from git tracking: git rm --cached .env.test
- add .env.test into .gitignore file
- add edit functionality for editing by submitter
- npm updates
-added xslt3 packeage for builfing sef files
- added Language.ts class vor language table
- added version to datasetxml2oai-pmh.xslt
2023-07-17 19:13:30 +02:00

67 lines
1.7 KiB
TypeScript

// import * as util from '../core/utilities';
import { EventEmitter } from './EventEmitter';
import type { Map } from 'leaflet/src/map/index';
export abstract class Control<T> extends EventEmitter<T> {
// @section
// @aka Control options
public options = {
position: 'topright',
};
protected _map;
protected _container;
// constructor(defaults?) {
// super();
// if (!(this instanceof Control)) {
// throw new TypeError("Control constructor cannot be called as a function.");
// }
// // properties
// // util.setOptions(this, defaults);
// }
public getPosition() {
return this.options.position;
}
public getContainer() {
return this._container;
}
public abstract onRemove(map): void;
public abstract onAdd(map: any): HTMLElement;
public addTo(map: Map): Control<T> {
this._map = map;
let container = (this._container = this.onAdd(map));
let pos = this.getPosition(); //"topright"
let corner = map.controlCorners[pos];
if (container) {
// $(container).addClass('gba-control');
container.classList.add('gba-control');
if (pos.indexOf('bottom') !== -1) {
corner.insertBefore(container, corner.firstChild);
} else {
corner.appendChild(container);
}
}
return this;
}
public removeFrom(map) {
let pos = this.getPosition();
let corner = map._controlCorners[pos];
corner.removeChild(this._container);
this._map = null;
if (this.onRemove) {
this.onRemove(map);
}
return this;
}
}