Skip to content

Commit

Permalink
Issue #1477 Enable loading spinner also for singleTile layers (ol.sou…
Browse files Browse the repository at this point in the history
…rce.ImageWMS) (#1478)
  • Loading branch information
mricca authored and mbarto committed Feb 17, 2017
1 parent 4e08679 commit 31b0a5e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions web/client/components/map/openlayers/Layer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 31b0a5e

Please sign in to comment.