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

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/source/OGCMapTile * @module ol/source/OGCMapTile
*/ */
import SourceState from './State.js';
import TileImage from './TileImage.js'; import TileImage from './TileImage.js';
import {getTileSetInfo} from './ogcTileUtil.js'; import {getTileSetInfo} from './ogcTileUtil.js';
@@ -60,7 +59,7 @@ class OGCMapTile extends TileImage {
interpolate: interpolate, interpolate: interpolate,
projection: options.projection, projection: options.projection,
reprojectionErrorThreshold: options.reprojectionErrorThreshold, reprojectionErrorThreshold: options.reprojectionErrorThreshold,
state: SourceState.LOADING, state: 'loading',
tileLoadFunction: options.tileLoadFunction, tileLoadFunction: options.tileLoadFunction,
wrapX: options.wrapX !== undefined ? options.wrapX : true, wrapX: options.wrapX !== undefined ? options.wrapX : true,
transition: options.transition, transition: options.transition,
@@ -85,7 +84,7 @@ class OGCMapTile extends TileImage {
handleTileSetInfo_(tileSetInfo) { handleTileSetInfo_(tileSetInfo) {
this.tileGrid = tileSetInfo.grid; this.tileGrid = tileSetInfo.grid;
this.setTileUrlFunction(tileSetInfo.urlFunction, tileSetInfo.urlTemplate); this.setTileUrlFunction(tileSetInfo.urlFunction, tileSetInfo.urlTemplate);
this.setState(SourceState.READY); this.setState('ready');
} }
/** /**
@@ -94,7 +93,7 @@ class OGCMapTile extends TileImage {
*/ */
handleError_(error) { handleError_(error) {
console.error(error); // eslint-disable-line no-console 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 * @module ol/source/OGCVectorTile
*/ */
import SourceState from './State.js';
import VectorTile from './VectorTile.js'; import VectorTile from './VectorTile.js';
import {getTileSetInfo} from './ogcTileUtil.js'; import {getTileSetInfo} from './ogcTileUtil.js';
@@ -61,7 +60,7 @@ class OGCVectorTile extends VectorTile {
transition: options.transition, transition: options.transition,
wrapX: options.wrapX, wrapX: options.wrapX,
zDirection: options.zDirection, zDirection: options.zDirection,
state: SourceState.LOADING, state: 'loading',
}); });
const sourceInfo = { const sourceInfo = {
@@ -84,7 +83,7 @@ class OGCVectorTile extends VectorTile {
handleTileSetInfo_(tileSetInfo) { handleTileSetInfo_(tileSetInfo) {
this.tileGrid = tileSetInfo.grid; this.tileGrid = tileSetInfo.grid;
this.setTileUrlFunction(tileSetInfo.urlFunction, tileSetInfo.urlTemplate); this.setTileUrlFunction(tileSetInfo.urlFunction, tileSetInfo.urlTemplate);
this.setState(SourceState.READY); this.setState('ready');
} }
/** /**
@@ -93,7 +92,7 @@ class OGCVectorTile extends VectorTile {
*/ */
handleError_(error) { handleError_(error) {
console.error(error); // eslint-disable-line no-console 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 GeoTIFFSource from '../../../../../src/ol/source/GeoTIFF.js';
import State from '../../../../../src/ol/source/State.js';
import TileState from '../../../../../src/ol/TileState.js'; import TileState from '../../../../../src/ol/TileState.js';
describe('ol/source/GeoTIFF', function () { describe('ol/source/GeoTIFF', function () {
@@ -115,9 +114,9 @@ describe('ol/source/GeoTIFF', function () {
}); });
it('manages load states', function (done) { it('manages load states', function (done) {
expect(source.getState()).to.be(State.LOADING); expect(source.getState()).to.be('loading');
source.on('change', () => { source.on('change', () => {
expect(source.getState()).to.be(State.READY); expect(source.getState()).to.be('ready');
done(); done();
}); });
}); });

View File

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