rlayers
Version:
React Components for OpenLayers
35 lines • 1.27 kB
JavaScript
import { Vector as LayerVector } 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 RLayerVector 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
});
this.ol = new LayerVector(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=RLayerVector.js.map