UNPKG

rlayers

Version:

React Components for OpenLayers

35 lines 1.27 kB
import { Tile as LayerTile } from 'ol/layer'; import { XYZ } from 'ol/source'; import { default as RLayerRaster } from './RLayerRaster'; /** * A layer with XYZ raster tiles * * Requires an `RMap` context */ export default class RLayerTile extends RLayerRaster { constructor(props, context) { super(props, context); this.createSource(); this.ol = new LayerTile({ source: this.source }); this.eventSources = [this.ol, this.source]; } createSource() { this.source = new XYZ({ url: this.props.url, interpolate: !this.props.noIterpolation, projection: this.props.projection, tileGrid: this.props.tileGrid, crossOrigin: this.props.crossOrigin }); 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=RLayerTile.js.map