UNPKG

rlayers

Version:

React Components for OpenLayers

40 lines 1.46 kB
import { WebGLTile as LayerTileWebGL } from 'ol/layer'; import { ImageTile as SourceImageTile } from 'ol/source'; import { default as RLayerWebGL } from './RLayerWebGL'; /** * A layer with XYZ raster tiles rendered by WebGL * * Requires an `RMap` context */ export default class RLayerTileWebGL extends RLayerWebGL { constructor(props) { super(props); this.createSource(); this.ol = new LayerTileWebGL({ opacity: 0.9, source: this.source, cacheSize: props.cacheSize }); this.eventSources = [this.ol, this.source]; } createSource() { this.source = new SourceImageTile({ url: this.props.url, interpolate: !this.props.noIterpolation, projection: this.props.projection, tileGrid: this.props.tileGrid, crossOrigin: 'anonymous', attributions: this.props.attributions }); this.eventSources = [this.ol, this.source]; } refresh(prevProps) { super.refresh(prevProps); if ((prevProps === null || prevProps === void 0 ? void 0 : prevProps.tileGrid) !== this.props.tileGrid || (prevProps === null || prevProps === void 0 ? void 0 : prevProps.url) !== this.props.url) { this.createSource(); this.ol.setSource(this.source); this.attachOldEventHandlers(this.source); } } } //# sourceMappingURL=RLayerTileWebGL.js.map