UNPKG

rlayers

Version:

React Components for OpenLayers

24 lines 896 B
import Geolocation from 'ol/Geolocation'; import { RlayersBase } from './REvent'; /** * A wrapper around the OpenLayers Geolocation helper * * Must have an `RMap` parent */ export default class RGeolocation extends RlayersBase { constructor(props) { super(props); this.ol = null; } render() { var _a, _b; if (!((_a = this === null || this === void 0 ? void 0 : this.context) === null || _a === void 0 ? void 0 : _a.map)) throw new Error('A Geolocation must be part of a map'); if (this.ol === null) { const projection = (_b = this.props.projection) !== null && _b !== void 0 ? _b : this.context.map.getView().getProjection(); this.ol = new Geolocation(Object.assign(Object.assign({}, this.props), { projection })); } return super.render(); } } //# sourceMappingURL=RGeolocation.js.map