diff --git a/web/client/components/map/openlayers/Layer.jsx b/web/client/components/map/openlayers/Layer.jsx index e4e74f5e5b..273ed399cd 100644 --- a/web/client/components/map/openlayers/Layer.jsx +++ b/web/client/components/map/openlayers/Layer.jsx @@ -37,6 +37,7 @@ const OpenlayersLayer = React.createClass({ componentDidMount() { this.valid = true; this.tilestoload = 0; + this.imagestoload = 0; this.createLayer(this.props.type, this.props.options, this.props.position); }, componentWillReceiveProps(newProps) { @@ -148,6 +149,27 @@ const OpenlayersLayer = React.createClass({ this.props.onLayerLoad(options.id, {error: event}); } }); + this.layer.getSource().on('imageloadstart', () => { + if (this.imagestoload === 0) { + this.props.onLayerLoading(options.id); + this.imagestoload++; + } else { + this.imagestoload++; + } + }); + this.layer.getSource().on('imageloadend', () => { + this.imagestoload--; + if (this.imagestoload === 0) { + this.props.onLayerLoad(options.id); + } + }); + this.layer.getSource().on('imageloaderror', (event) => { + this.imagestoload--; + this.props.onLayerError(options.id); + if (this.imagestoload === 0) { + this.props.onLayerLoad(options.id, {error: event}); + } + }); } }, isValid() {