Additional uses of new source state type

This commit is contained in:
Tim Schaub
2021-09-04 16:50:09 -06:00
committed by Andreas Hocevar
parent 57f147988d
commit 04ad0e0c5a
5 changed files with 10 additions and 15 deletions

3
examples/d3.js vendored
View File

@@ -1,5 +1,4 @@
import Map from '../src/ol/Map.js';
import SourceState from '../src/ol/source/State.js';
import Stamen from '../src/ol/source/Stamen.js';
import View from '../src/ol/View.js';
import {Layer, Tile as TileLayer} from '../src/ol/layer.js';
@@ -21,7 +20,7 @@ class CanvasLayer extends Layer {
}
getSourceState() {
return SourceState.READY;
return 'ready';
}
render(frameState) {

View File

@@ -1,7 +1,6 @@
/**
* @module ol/source/OGCMapTile
*/
import SourceState from './State.js';
import TileImage from './TileImage.js';
import {getTileSetInfo} from './ogcTileUtil.js';
@@ -60,7 +59,7 @@ class OGCMapTile extends TileImage {
interpolate: interpolate,
projection: options.projection,
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
state: SourceState.LOADING,
state: 'loading',
tileLoadFunction: options.tileLoadFunction,
wrapX: options.wrapX !== undefined ? options.wrapX : true,
transition: options.transition,
@@ -85,7 +84,7 @@ class OGCMapTile extends TileImage {
handleTileSetInfo_(tileSetInfo) {
this.tileGrid = tileSetInfo.grid;
this.setTileUrlFunction(tileSetInfo.urlFunction, tileSetInfo.urlTemplate);
this.setState(SourceState.READY);
this.setState('ready');
}
/**
@@ -94,7 +93,7 @@ class OGCMapTile extends TileImage {
*/
handleError_(error) {
console.error(error); // eslint-disable-line no-console
this.setState(SourceState.ERROR);
this.setState('error');
}
}

View File

@@ -2,7 +2,6 @@
* @module ol/source/OGCVectorTile
*/
import SourceState from './State.js';
import VectorTile from './VectorTile.js';
import {getTileSetInfo} from './ogcTileUtil.js';
@@ -61,7 +60,7 @@ class OGCVectorTile extends VectorTile {
transition: options.transition,
wrapX: options.wrapX,
zDirection: options.zDirection,
state: SourceState.LOADING,
state: 'loading',
});
const sourceInfo = {
@@ -84,7 +83,7 @@ class OGCVectorTile extends VectorTile {
handleTileSetInfo_(tileSetInfo) {
this.tileGrid = tileSetInfo.grid;
this.setTileUrlFunction(tileSetInfo.urlFunction, tileSetInfo.urlTemplate);
this.setState(SourceState.READY);
this.setState('ready');
}
/**
@@ -93,7 +92,7 @@ class OGCVectorTile extends VectorTile {
*/
handleError_(error) {
console.error(error); // eslint-disable-line no-console
this.setState(SourceState.ERROR);
this.setState('error');
}
}

View File

@@ -1,5 +1,4 @@
import GeoTIFFSource from '../../../../../src/ol/source/GeoTIFF.js';
import State from '../../../../../src/ol/source/State.js';
import TileState from '../../../../../src/ol/TileState.js';
describe('ol/source/GeoTIFF', function () {
@@ -115,9 +114,9 @@ describe('ol/source/GeoTIFF', function () {
});
it('manages load states', function (done) {
expect(source.getState()).to.be(State.LOADING);
expect(source.getState()).to.be('loading');
source.on('change', () => {
expect(source.getState()).to.be(State.READY);
expect(source.getState()).to.be('ready');
done();
});
});

View File

@@ -7,7 +7,6 @@
import Control from '../../../../src/ol/control/Control.js';
import Layer from '../../../../src/ol/layer/Layer.js';
import Map from '../../../../src/ol/Map.js';
import SourceState from '../../../../src/ol/source/State.js';
import View from '../../../../src/ol/View.js';
class Element extends Layer {
@@ -22,7 +21,7 @@ class Element extends Layer {
}
getSourceState() {
return SourceState.READY;
return 'ready';
}
render() {