UNPKG

rlayers

Version:

React Components for OpenLayers

37 lines 1.43 kB
import { VectorImage as LayerVectorImage } from 'ol/layer'; import { Vector as SourceVector } from 'ol/source'; import { default as RLayerBaseVector } from './RLayerBaseVector'; import { isOLFlatStyle, 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 }); const style = isOLFlatStyle(props.style) ? props.style : RStyle.getStyle(props.style); this.ol = new LayerVectorImage(Object.assign(Object.assign({}, props), { style: 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