UNPKG

rlayers

Version:

React Components for OpenLayers

30 lines 1.45 kB
import LayerGraticule from 'ol/layer/Graticule'; import { default as RLayer } from './RLayer'; import { RStyle } from 'rlayers/style'; /** * A layer that renders a static image */ export default class RLayerGraticule extends RLayer { constructor(props) { super(props); this.createSource(); } createSource() { var _a, _b, _c, _d, _e, _f; const stroke = (_b = (_a = RStyle.getStyleStatic(this.props.strokeStyle)) === null || _a === void 0 ? void 0 : _a.getStroke) === null || _b === void 0 ? void 0 : _b.call(_a); const lonText = (_d = (_c = RStyle.getStyleStatic(this.props.lonLabelStyle)) === null || _c === void 0 ? void 0 : _c.getText) === null || _d === void 0 ? void 0 : _d.call(_c); const latText = (_f = (_e = RStyle.getStyleStatic(this.props.latLabelStyle)) === null || _e === void 0 ? void 0 : _e.getText) === null || _f === void 0 ? void 0 : _f.call(_e); this.ol = new LayerGraticule(Object.assign(Object.assign({}, this.props), { strokeStyle: stroke, lonLabelStyle: lonText, latLabelStyle: latText })); this.eventSources = [this.ol]; return; } refresh(prevProps) { super.refresh(prevProps); const old = this.context.map.removeLayer(this.ol); this.createSource(); this.attachOldEventHandlers(this.ol); if (old) this.context.map.addLayer(this.ol); } } //# sourceMappingURL=RLayerGraticule.js.map