Use union type for source state
This commit is contained in:
@@ -260,7 +260,7 @@ class BaseLayer extends BaseObject {
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return {import("../source/State.js").default} Source state.
|
||||
* @return {import("../source/Source.js").State} Source state.
|
||||
*/
|
||||
getSourceState() {
|
||||
return abstract();
|
||||
|
||||
@@ -7,7 +7,6 @@ import CollectionEventType from '../CollectionEventType.js';
|
||||
import Event from '../events/Event.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import ObjectEventType from '../ObjectEventType.js';
|
||||
import SourceState from '../source/State.js';
|
||||
import {assert} from '../asserts.js';
|
||||
import {assign, clear} from '../obj.js';
|
||||
import {getIntersection} from '../extent.js';
|
||||
@@ -343,10 +342,10 @@ class LayerGroup extends BaseLayer {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {import("../source/State.js").default} Source state.
|
||||
* @return {import("../source/Source.js").State} Source state.
|
||||
*/
|
||||
getSourceState() {
|
||||
return SourceState.READY;
|
||||
return 'ready';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import BaseLayer from './Base.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import LayerProperty from './Property.js';
|
||||
import RenderEventType from '../render/EventType.js';
|
||||
import SourceState from '../source/State.js';
|
||||
import {assert} from '../asserts.js';
|
||||
import {assign} from '../obj.js';
|
||||
import {listen, unlistenByKey} from '../events.js';
|
||||
@@ -213,7 +212,7 @@ class Layer extends BaseLayer {
|
||||
*/
|
||||
getSourceState() {
|
||||
const source = this.getSource();
|
||||
return !source ? SourceState.UNDEFINED : source.getState();
|
||||
return !source ? 'undefined' : source.getState();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import BaseEvent from '../events/Event.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import MVT from '../format/MVT.js';
|
||||
import SourceState from '../source/State.js';
|
||||
import VectorTileLayer from '../layer/VectorTile.js';
|
||||
import VectorTileSource from '../source/VectorTile.js';
|
||||
import {applyBackground, applyStyle} from 'ol-mapbox-style';
|
||||
@@ -144,7 +143,7 @@ class MapboxVectorLayer extends VectorTileLayer {
|
||||
constructor(options) {
|
||||
const declutter = 'declutter' in options ? options.declutter : true;
|
||||
const source = new VectorTileSource({
|
||||
state: SourceState.LOADING,
|
||||
state: 'loading',
|
||||
format: new MVT(),
|
||||
});
|
||||
|
||||
@@ -179,12 +178,12 @@ class MapboxVectorLayer extends VectorTileLayer {
|
||||
accessToken: this.accessToken,
|
||||
})
|
||||
.then(() => {
|
||||
source.setState(SourceState.READY);
|
||||
source.setState('ready');
|
||||
})
|
||||
.catch((error) => {
|
||||
this.dispatchEvent(new ErrorEvent(error));
|
||||
const source = this.getSource();
|
||||
source.setState(SourceState.ERROR);
|
||||
source.setState('error');
|
||||
});
|
||||
if (this.getBackground() === undefined) {
|
||||
applyBackground(this, options.styleUrl, {
|
||||
|
||||
Reference in New Issue
Block a user