UNPKG

rlayers

Version:

React Components for OpenLayers

55 lines 2.31 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var REvent_1 = require("../REvent"); /** * An abstract class serving as base for all controls, not meant to be used directly */ var RControlBase = /** @class */ (function (_super) { __extends(RControlBase, _super); function RControlBase(props) { return _super.call(this, props) || this; } RControlBase.prototype.toOLProps = function (props) { var _a; return { className: props.className, target: (_a = props.target) === null || _a === void 0 ? void 0 : _a.current }; }; RControlBase.prototype.refresh = function (prevProps) { _super.prototype.refresh.call(this, prevProps); this.ol.setProperties(this.toOLProps(this.props)); }; RControlBase.prototype.componentDidMount = function () { _super.prototype.componentDidMount.call(this); this.context.map.addControl(this.ol); }; RControlBase.prototype.componentWillUnmount = function () { _super.prototype.componentWillUnmount.call(this); this.context.map.removeControl(this.ol); }; RControlBase.prototype.render = function () { var _a; if (!((_a = this.context) === null || _a === void 0 ? void 0 : _a.map)) throw new Error('A control must be part of a map'); return _super.prototype.render.call(this); }; return RControlBase; }(REvent_1.RlayersBase)); exports.default = RControlBase; //# sourceMappingURL=RControlBase.js.map