rlayers
Version:
React Components for OpenLayers
34 lines • 1.2 kB
JavaScript
import LayerImage from 'ol/layer/Image';
import SourceImage from 'ol/source/ImageStatic';
import { default as RLayer } from './RLayer';
/**
* A layer that renders a static image
*/
export default class RLayerImage extends RLayer {
constructor(props, context) {
super(props, context);
this.createSource();
this.ol = new LayerImage({ source: this.source });
this.eventSources = [this.ol, this.source];
}
createSource() {
const options = {
url: this.props.url,
projection: this.props.projection,
imageExtent: this.props.extent,
imageSize: this.props.size
};
this.source = new SourceImage(options);
this.eventSources = [this.ol, this.source];
}
refresh(prevProps) {
super.refresh(prevProps);
if (this.props.url && (prevProps === null || prevProps === void 0 ? void 0 : prevProps.url) !== this.props.url) {
this.createSource();
this.ol.setSource(this.source);
this.eventSources = [this.ol, this.source];
this.attachOldEventHandlers(this.source);
}
}
}
//# sourceMappingURL=RLayerImage.js.map