UNPKG

rlayers

Version:

React Components for OpenLayers

36 lines 1.34 kB
import { VectorImage as LayerVectorImage } from 'ol/layer'; import { Vector as SourceVector } from 'ol/source'; import { default as RLayerBaseVector } from './RLayerBaseVector'; import { default as RStyle } from '../style/RStyle'; /** * A vector layer * * Supports loading of features from external sources * * Requires an `RMap` context * * Provides a vector layer context for JSX-declared `RFeature`s */ export default class RLayerVectorImage extends RLayerBaseVector { createSource(props) { this.source = new SourceVector({ features: this.props.features, url: this.props.url, format: this.props.format, loader: this.props.loader, wrapX: this.props.wrapX, strategy: this.props.strategy, attributions: this.props.attributions }); this.ol = new LayerVectorImage(Object.assign(Object.assign({}, props), { style: RStyle.getStyle(this.props.style), source: this.source })); return [this.ol, this.source]; } refresh(prevProps) { super.refresh(prevProps); if ((prevProps === null || prevProps === void 0 ? void 0 : prevProps.url) !== this.props.url) { this.source.setUrl(this.props.url); this.source.refresh(); } } } //# sourceMappingURL=RLayerVectorImage.js.map