Use union type for source state
This commit is contained in:
@@ -260,7 +260,7 @@ class BaseLayer extends BaseObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
* @return {import("../source/State.js").default} Source state.
|
* @return {import("../source/Source.js").State} Source state.
|
||||||
*/
|
*/
|
||||||
getSourceState() {
|
getSourceState() {
|
||||||
return abstract();
|
return abstract();
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import CollectionEventType from '../CollectionEventType.js';
|
|||||||
import Event from '../events/Event.js';
|
import Event from '../events/Event.js';
|
||||||
import EventType from '../events/EventType.js';
|
import EventType from '../events/EventType.js';
|
||||||
import ObjectEventType from '../ObjectEventType.js';
|
import ObjectEventType from '../ObjectEventType.js';
|
||||||
import SourceState from '../source/State.js';
|
|
||||||
import {assert} from '../asserts.js';
|
import {assert} from '../asserts.js';
|
||||||
import {assign, clear} from '../obj.js';
|
import {assign, clear} from '../obj.js';
|
||||||
import {getIntersection} from '../extent.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() {
|
getSourceState() {
|
||||||
return SourceState.READY;
|
return 'ready';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import BaseLayer from './Base.js';
|
|||||||
import EventType from '../events/EventType.js';
|
import EventType from '../events/EventType.js';
|
||||||
import LayerProperty from './Property.js';
|
import LayerProperty from './Property.js';
|
||||||
import RenderEventType from '../render/EventType.js';
|
import RenderEventType from '../render/EventType.js';
|
||||||
import SourceState from '../source/State.js';
|
|
||||||
import {assert} from '../asserts.js';
|
import {assert} from '../asserts.js';
|
||||||
import {assign} from '../obj.js';
|
import {assign} from '../obj.js';
|
||||||
import {listen, unlistenByKey} from '../events.js';
|
import {listen, unlistenByKey} from '../events.js';
|
||||||
@@ -213,7 +212,7 @@ class Layer extends BaseLayer {
|
|||||||
*/
|
*/
|
||||||
getSourceState() {
|
getSourceState() {
|
||||||
const source = this.getSource();
|
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 BaseEvent from '../events/Event.js';
|
||||||
import EventType from '../events/EventType.js';
|
import EventType from '../events/EventType.js';
|
||||||
import MVT from '../format/MVT.js';
|
import MVT from '../format/MVT.js';
|
||||||
import SourceState from '../source/State.js';
|
|
||||||
import VectorTileLayer from '../layer/VectorTile.js';
|
import VectorTileLayer from '../layer/VectorTile.js';
|
||||||
import VectorTileSource from '../source/VectorTile.js';
|
import VectorTileSource from '../source/VectorTile.js';
|
||||||
import {applyBackground, applyStyle} from 'ol-mapbox-style';
|
import {applyBackground, applyStyle} from 'ol-mapbox-style';
|
||||||
@@ -144,7 +143,7 @@ class MapboxVectorLayer extends VectorTileLayer {
|
|||||||
constructor(options) {
|
constructor(options) {
|
||||||
const declutter = 'declutter' in options ? options.declutter : true;
|
const declutter = 'declutter' in options ? options.declutter : true;
|
||||||
const source = new VectorTileSource({
|
const source = new VectorTileSource({
|
||||||
state: SourceState.LOADING,
|
state: 'loading',
|
||||||
format: new MVT(),
|
format: new MVT(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -179,12 +178,12 @@ class MapboxVectorLayer extends VectorTileLayer {
|
|||||||
accessToken: this.accessToken,
|
accessToken: this.accessToken,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
source.setState(SourceState.READY);
|
source.setState('ready');
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.dispatchEvent(new ErrorEvent(error));
|
this.dispatchEvent(new ErrorEvent(error));
|
||||||
const source = this.getSource();
|
const source = this.getSource();
|
||||||
source.setState(SourceState.ERROR);
|
source.setState('error');
|
||||||
});
|
});
|
||||||
if (this.getBackground() === undefined) {
|
if (this.getBackground() === undefined) {
|
||||||
applyBackground(this, options.styleUrl, {
|
applyBackground(this, options.styleUrl, {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import MapRenderer from './Map.js';
|
|||||||
import ObjectEventType from '../ObjectEventType.js';
|
import ObjectEventType from '../ObjectEventType.js';
|
||||||
import RenderEvent from '../render/Event.js';
|
import RenderEvent from '../render/Event.js';
|
||||||
import RenderEventType from '../render/EventType.js';
|
import RenderEventType from '../render/EventType.js';
|
||||||
import SourceState from '../source/State.js';
|
|
||||||
import {CLASS_UNSELECTABLE} from '../css.js';
|
import {CLASS_UNSELECTABLE} from '../css.js';
|
||||||
import {checkedFonts} from '../render/canvas.js';
|
import {checkedFonts} from '../render/canvas.js';
|
||||||
import {inView} from '../layer/Layer.js';
|
import {inView} from '../layer/Layer.js';
|
||||||
@@ -115,8 +114,8 @@ class CompositeMapRenderer extends MapRenderer {
|
|||||||
const sourceState = layer.getSourceState();
|
const sourceState = layer.getSourceState();
|
||||||
if (
|
if (
|
||||||
!inView(layerState, viewState) ||
|
!inView(layerState, viewState) ||
|
||||||
(sourceState != SourceState.READY &&
|
(layerState.sourceState != 'ready' &&
|
||||||
sourceState != SourceState.UNDEFINED)
|
layerState.sourceState != 'undefined')
|
||||||
) {
|
) {
|
||||||
layer.unrender();
|
layer.unrender();
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
import EventType from '../events/EventType.js';
|
import EventType from '../events/EventType.js';
|
||||||
import ImageState from '../ImageState.js';
|
import ImageState from '../ImageState.js';
|
||||||
import Observable from '../Observable.js';
|
import Observable from '../Observable.js';
|
||||||
import SourceState from '../source/State.js';
|
|
||||||
import {abstract} from '../util.js';
|
import {abstract} from '../util.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -199,7 +198,7 @@ class LayerRenderer extends Observable {
|
|||||||
if (
|
if (
|
||||||
layer &&
|
layer &&
|
||||||
layer.getVisible() &&
|
layer.getVisible() &&
|
||||||
layer.getSourceState() == SourceState.READY
|
'ready'
|
||||||
) {
|
) {
|
||||||
layer.changed();
|
layer.changed();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
* @module ol/renderer/webgl/TileLayer
|
* @module ol/renderer/webgl/TileLayer
|
||||||
*/
|
*/
|
||||||
import LRUCache from '../../structs/LRUCache.js';
|
import LRUCache from '../../structs/LRUCache.js';
|
||||||
import State from '../../source/State.js';
|
|
||||||
import TileRange from '../../TileRange.js';
|
import TileRange from '../../TileRange.js';
|
||||||
import TileState from '../../TileState.js';
|
import TileState from '../../TileState.js';
|
||||||
import TileTexture from '../../webgl/TileTexture.js';
|
import TileTexture from '../../webgl/TileTexture.js';
|
||||||
@@ -309,7 +308,7 @@ class WebGLTileLayerRenderer extends WebGLLayerRenderer {
|
|||||||
if (isEmpty(getRenderExtent(frameState, frameState.extent))) {
|
if (isEmpty(getRenderExtent(frameState, frameState.extent))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return source.getState() === State.READY;
|
return source.getState() === 'ready';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
* @module ol/source/BingMaps
|
* @module ol/source/BingMaps
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import SourceState from './State.js';
|
|
||||||
import TileImage from './TileImage.js';
|
import TileImage from './TileImage.js';
|
||||||
import {applyTransform, intersects} from '../extent.js';
|
import {applyTransform, intersects} from '../extent.js';
|
||||||
import {createFromTileUrlFunctions} from '../tileurlfunction.js';
|
import {createFromTileUrlFunctions} from '../tileurlfunction.js';
|
||||||
@@ -135,7 +134,7 @@ class BingMaps extends TileImage {
|
|||||||
opaque: true,
|
opaque: true,
|
||||||
projection: getProjection('EPSG:3857'),
|
projection: getProjection('EPSG:3857'),
|
||||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||||
state: SourceState.LOADING,
|
state: 'loading',
|
||||||
tileLoadFunction: options.tileLoadFunction,
|
tileLoadFunction: options.tileLoadFunction,
|
||||||
tilePixelRatio: hidpi ? 2 : 1,
|
tilePixelRatio: hidpi ? 2 : 1,
|
||||||
wrapX: options.wrapX !== undefined ? options.wrapX : true,
|
wrapX: options.wrapX !== undefined ? options.wrapX : true,
|
||||||
@@ -220,7 +219,7 @@ class BingMaps extends TileImage {
|
|||||||
response.resourceSets.length != 1 ||
|
response.resourceSets.length != 1 ||
|
||||||
response.resourceSets[0].resources.length != 1
|
response.resourceSets[0].resources.length != 1
|
||||||
) {
|
) {
|
||||||
this.setState(SourceState.ERROR);
|
this.setState('error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,7 +328,7 @@ class BingMaps extends TileImage {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState(SourceState.READY);
|
this.setState('ready');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
* @module ol/source/CartoDB
|
* @module ol/source/CartoDB
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import SourceState from './State.js';
|
|
||||||
import XYZ from './XYZ.js';
|
import XYZ from './XYZ.js';
|
||||||
import {assign} from '../obj.js';
|
import {assign} from '../obj.js';
|
||||||
|
|
||||||
@@ -165,14 +164,14 @@ class CartoDB extends XYZ {
|
|||||||
JSON.parse(client.responseText)
|
JSON.parse(client.responseText)
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.setState(SourceState.ERROR);
|
this.setState('error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.applyTemplate_(response);
|
this.applyTemplate_(response);
|
||||||
this.templateCache_[paramHash] = response;
|
this.templateCache_[paramHash] = response;
|
||||||
this.setState(SourceState.READY);
|
this.setState('ready');
|
||||||
} else {
|
} else {
|
||||||
this.setState(SourceState.ERROR);
|
this.setState('error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +180,7 @@ class CartoDB extends XYZ {
|
|||||||
* @param {Event} event Event.
|
* @param {Event} event Event.
|
||||||
*/
|
*/
|
||||||
handleInitError_(event) {
|
handleInitError_(event) {
|
||||||
this.setState(SourceState.ERROR);
|
this.setState('error');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import {toSize} from '../size.js';
|
|||||||
* @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Tile projection.
|
* @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Tile projection.
|
||||||
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid.
|
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid.
|
||||||
* @property {boolean} [opaque=false] Whether the layer is opaque.
|
* @property {boolean} [opaque=false] Whether the layer is opaque.
|
||||||
* @property {import("./State.js").default} [state] The source state.
|
* @property {import("./Source.js").State} [state] The source state.
|
||||||
* @property {number} [tilePixelRatio] Deprecated. To have tiles scaled, pass a `tileSize` representing
|
* @property {number} [tilePixelRatio] Deprecated. To have tiles scaled, pass a `tileSize` representing
|
||||||
* the source tile size and a `tileGrid` with the desired rendered tile size.
|
* the source tile size and a `tileGrid` with the desired rendered tile size.
|
||||||
* @property {boolean} [wrapX=false] Render tiles beyond the antimeridian.
|
* @property {boolean} [wrapX=false] Render tiles beyond the antimeridian.
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
* @module ol/source/GeoTIFF
|
* @module ol/source/GeoTIFF
|
||||||
*/
|
*/
|
||||||
import DataTile from './DataTile.js';
|
import DataTile from './DataTile.js';
|
||||||
import State from './State.js';
|
|
||||||
import TileGrid from '../tilegrid/TileGrid.js';
|
import TileGrid from '../tilegrid/TileGrid.js';
|
||||||
import {
|
import {
|
||||||
Pool,
|
Pool,
|
||||||
@@ -335,7 +334,7 @@ class GeoTIFFSource extends DataTile {
|
|||||||
*/
|
*/
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super({
|
super({
|
||||||
state: State.LOADING,
|
state: 'loading',
|
||||||
tileGrid: null,
|
tileGrid: null,
|
||||||
projection: null,
|
projection: null,
|
||||||
opaque: options.opaque,
|
opaque: options.opaque,
|
||||||
@@ -428,7 +427,7 @@ class GeoTIFFSource extends DataTile {
|
|||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
console.error(error); // eslint-disable-line no-console
|
console.error(error); // eslint-disable-line no-console
|
||||||
self.error_ = error;
|
self.error_ = error;
|
||||||
self.setState(State.ERROR);
|
self.setState('error');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -650,7 +649,7 @@ class GeoTIFFSource extends DataTile {
|
|||||||
this.setTileSizes(commonSourceTileSizes);
|
this.setTileSizes(commonSourceTileSizes);
|
||||||
|
|
||||||
this.setLoader(this.loadTile_.bind(this));
|
this.setLoader(this.loadTile_.bind(this));
|
||||||
this.setState(State.READY);
|
this.setState('ready');
|
||||||
this.viewResolver({
|
this.viewResolver({
|
||||||
projection: this.projection,
|
projection: this.projection,
|
||||||
resolutions: resolutions,
|
resolutions: resolutions,
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import {toSize} from '../size.js';
|
|||||||
* @property {import("../size.js").Size} size Size of the image [width, height].
|
* @property {import("../size.js").Size} size Size of the image [width, height].
|
||||||
* @property {Array<import("../size.js").Size>} [sizes] Supported scaled image sizes.
|
* @property {Array<import("../size.js").Size>} [sizes] Supported scaled image sizes.
|
||||||
* Content of the IIIF info.json 'sizes' property, but as array of Size objects.
|
* Content of the IIIF info.json 'sizes' property, but as array of Size objects.
|
||||||
* @property {import("./State.js").default} [state] Source state.
|
* @property {import("./Source.js").State} [state] Source state.
|
||||||
* @property {Array<string>} [supports=[]] Supported IIIF region and size calculation
|
* @property {Array<string>} [supports=[]] Supported IIIF region and size calculation
|
||||||
* features.
|
* features.
|
||||||
* @property {number} [tilePixelRatio] Tile pixel ratio.
|
* @property {number} [tilePixelRatio] Tile pixel ratio.
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export class ImageSourceEvent extends Event {
|
|||||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||||
* @property {import("../proj.js").ProjectionLike} [projection] Projection.
|
* @property {import("../proj.js").ProjectionLike} [projection] Projection.
|
||||||
* @property {Array<number>} [resolutions] Resolutions.
|
* @property {Array<number>} [resolutions] Resolutions.
|
||||||
* @property {import("./State.js").default} [state] State.
|
* @property {import("./Source.js").State} [state] State.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ import {
|
|||||||
* width and height of the map viewport, and so on. Must be `1` or higher.
|
* width and height of the map viewport, and so on. Must be `1` or higher.
|
||||||
* @property {Array<number>} [resolutions] Resolutions.
|
* @property {Array<number>} [resolutions] Resolutions.
|
||||||
* If specified, new canvases will be created for these resolutions
|
* If specified, new canvases will be created for these resolutions
|
||||||
* @property {import("./State.js").default} [state] Source state.
|
* @property {import("./Source.js").State} [state] Source state.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import ImageCanvas from '../ImageCanvas.js';
|
|||||||
import ImageLayer from '../layer/Image.js';
|
import ImageLayer from '../layer/Image.js';
|
||||||
import ImageSource from './Image.js';
|
import ImageSource from './Image.js';
|
||||||
import Source from './Source.js';
|
import Source from './Source.js';
|
||||||
import SourceState from './State.js';
|
|
||||||
import TileLayer from '../layer/Tile.js';
|
import TileLayer from '../layer/Tile.js';
|
||||||
import TileQueue from '../TileQueue.js';
|
import TileQueue from '../TileQueue.js';
|
||||||
import TileSource from './Tile.js';
|
import TileSource from './Tile.js';
|
||||||
@@ -743,7 +742,7 @@ class RasterSource extends ImageSource {
|
|||||||
let source;
|
let source;
|
||||||
for (let i = 0, ii = this.layers_.length; i < ii; ++i) {
|
for (let i = 0, ii = this.layers_.length; i < ii; ++i) {
|
||||||
source = this.layers_[i].getSource();
|
source = this.layers_[i].getSource();
|
||||||
if (source.getState() !== SourceState.READY) {
|
if (source.getState() !== 'ready') {
|
||||||
ready = false;
|
ready = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,14 @@
|
|||||||
* @module ol/source/Source
|
* @module ol/source/Source
|
||||||
*/
|
*/
|
||||||
import BaseObject from '../Object.js';
|
import BaseObject from '../Object.js';
|
||||||
import SourceState from './State.js';
|
|
||||||
import {abstract} from '../util.js';
|
import {abstract} from '../util.js';
|
||||||
import {get as getProjection} from '../proj.js';
|
import {get as getProjection} from '../proj.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {'undefined' | 'loading' | 'ready' | 'error'} State
|
||||||
|
* State of the source, one of 'undefined', 'loading', 'ready' or 'error'.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function that takes a {@link module:ol/PluggableMap~FrameState} and returns a string or
|
* A function that takes a {@link module:ol/PluggableMap~FrameState} and returns a string or
|
||||||
* an array of strings representing source attributions.
|
* an array of strings representing source attributions.
|
||||||
@@ -29,7 +33,7 @@ import {get as getProjection} from '../proj.js';
|
|||||||
* @property {AttributionLike} [attributions] Attributions.
|
* @property {AttributionLike} [attributions] Attributions.
|
||||||
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
|
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
|
||||||
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
|
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
|
||||||
* @property {import("./State.js").default} [state='ready'] State.
|
* @property {import("./Source.js").State} [state='ready'] State.
|
||||||
* @property {boolean} [wrapX=false] WrapX.
|
* @property {boolean} [wrapX=false] WrapX.
|
||||||
* @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
|
* @property {boolean} [interpolate=false] Use interpolated values when resampling. By default,
|
||||||
* the nearest neighbor is used when resampling.
|
* the nearest neighbor is used when resampling.
|
||||||
@@ -82,10 +86,9 @@ class Source extends BaseObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {import("./State.js").default}
|
* @type {import("./Source.js").State}
|
||||||
*/
|
*/
|
||||||
this.state_ =
|
this.state_ = options.state !== undefined ? options.state : 'ready';
|
||||||
options.state !== undefined ? options.state : SourceState.READY;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -164,8 +167,8 @@ class Source extends BaseObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the state of the source, see {@link module:ol/source/State~State} for possible states.
|
* Get the state of the source, see {@link import("./Source.js").State} for possible states.
|
||||||
* @return {import("./State.js").default} State.
|
* @return {import("./Source.js").State} State.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
getState() {
|
getState() {
|
||||||
@@ -208,7 +211,7 @@ class Source extends BaseObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the state of the source.
|
* Set the state of the source.
|
||||||
* @param {import("./State.js").default} state State.
|
* @param {import("./Source.js").State} state State.
|
||||||
*/
|
*/
|
||||||
setState(state) {
|
setState(state) {
|
||||||
this.state_ = state;
|
this.state_ = state;
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
/**
|
|
||||||
* @module ol/source/State
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum {string}
|
|
||||||
* State of the source, one of 'undefined', 'loading', 'ready' or 'error'.
|
|
||||||
*/
|
|
||||||
export default {
|
|
||||||
UNDEFINED: 'undefined',
|
|
||||||
LOADING: 'loading',
|
|
||||||
READY: 'ready',
|
|
||||||
ERROR: 'error',
|
|
||||||
};
|
|
||||||
@@ -32,7 +32,7 @@ import {scale as scaleSize, toSize} from '../size.js';
|
|||||||
* @property {boolean} [opaque=false] Whether the layer is opaque.
|
* @property {boolean} [opaque=false] Whether the layer is opaque.
|
||||||
* @property {number} [tilePixelRatio] TilePixelRatio.
|
* @property {number} [tilePixelRatio] TilePixelRatio.
|
||||||
* @property {import("../proj.js").ProjectionLike} [projection] Projection.
|
* @property {import("../proj.js").ProjectionLike} [projection] Projection.
|
||||||
* @property {import("./State.js").default} [state] State.
|
* @property {import("./Source.js").State} [state] State.
|
||||||
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] TileGrid.
|
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] TileGrid.
|
||||||
* @property {boolean} [wrapX=false] WrapX.
|
* @property {boolean} [wrapX=false] WrapX.
|
||||||
* @property {number} [transition] Transition.
|
* @property {number} [transition] Transition.
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import {getUid} from '../util.js';
|
|||||||
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
|
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
|
||||||
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
|
* @property {number} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels).
|
||||||
* Higher values can increase reprojection performance, but decrease precision.
|
* Higher values can increase reprojection performance, but decrease precision.
|
||||||
* @property {import("./State.js").default} [state] Source state.
|
* @property {import("./Source.js").State} [state] Source state.
|
||||||
* @property {typeof import("../ImageTile.js").default} [tileClass] Class used to instantiate image tiles.
|
* @property {typeof import("../ImageTile.js").default} [tileClass] Class used to instantiate image tiles.
|
||||||
* Default is {@link module:ol/ImageTile~ImageTile}.
|
* Default is {@link module:ol/ImageTile~ImageTile}.
|
||||||
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid.
|
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid.
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
* See https://mapbox.com/developers/api/.
|
* See https://mapbox.com/developers/api/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import SourceState from './State.js';
|
|
||||||
import TileImage from './TileImage.js';
|
import TileImage from './TileImage.js';
|
||||||
import {applyTransform, intersects} from '../extent.js';
|
import {applyTransform, intersects} from '../extent.js';
|
||||||
import {assert} from '../asserts.js';
|
import {assert} from '../asserts.js';
|
||||||
@@ -89,7 +88,7 @@ class TileJSON extends TileImage {
|
|||||||
interpolate: interpolate,
|
interpolate: interpolate,
|
||||||
projection: getProjection('EPSG:3857'),
|
projection: getProjection('EPSG:3857'),
|
||||||
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,
|
||||||
@@ -206,14 +205,14 @@ class TileJSON extends TileImage {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.tileJSON_ = tileJSON;
|
this.tileJSON_ = tileJSON;
|
||||||
this.setState(SourceState.READY);
|
this.setState('ready');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
handleTileJSONError() {
|
handleTileJSONError() {
|
||||||
this.setState(SourceState.ERROR);
|
this.setState('error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import EventType from '../events/EventType.js';
|
import EventType from '../events/EventType.js';
|
||||||
import SourceState from './State.js';
|
|
||||||
import Tile from '../Tile.js';
|
import Tile from '../Tile.js';
|
||||||
import TileSource from './Tile.js';
|
import TileSource from './Tile.js';
|
||||||
import TileState from '../TileState.js';
|
import TileState from '../TileState.js';
|
||||||
@@ -285,7 +284,7 @@ class UTFGrid extends TileSource {
|
|||||||
constructor(options) {
|
constructor(options) {
|
||||||
super({
|
super({
|
||||||
projection: getProjection('EPSG:3857'),
|
projection: getProjection('EPSG:3857'),
|
||||||
state: SourceState.LOADING,
|
state: 'loading',
|
||||||
zDirection: options.zDirection,
|
zDirection: options.zDirection,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -420,7 +419,7 @@ class UTFGrid extends TileSource {
|
|||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
handleTileJSONError() {
|
handleTileJSONError() {
|
||||||
this.setState(SourceState.ERROR);
|
this.setState('error');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -455,7 +454,7 @@ class UTFGrid extends TileSource {
|
|||||||
|
|
||||||
const grids = tileJSON['grids'];
|
const grids = tileJSON['grids'];
|
||||||
if (!grids) {
|
if (!grids) {
|
||||||
this.setState(SourceState.ERROR);
|
this.setState('error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,7 +470,7 @@ class UTFGrid extends TileSource {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState(SourceState.READY);
|
this.setState('ready');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {getUid} from '../util.js';
|
|||||||
* @property {number} [cacheSize] Cache size.
|
* @property {number} [cacheSize] Cache size.
|
||||||
* @property {boolean} [opaque=false] Whether the layer is opaque.
|
* @property {boolean} [opaque=false] Whether the layer is opaque.
|
||||||
* @property {import("../proj.js").ProjectionLike} [projection] Projection.
|
* @property {import("../proj.js").ProjectionLike} [projection] Projection.
|
||||||
* @property {import("./State.js").default} [state] State.
|
* @property {import("./Source.js").State} [state] State.
|
||||||
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] TileGrid.
|
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] TileGrid.
|
||||||
* @property {import("../Tile.js").LoadFunction} tileLoadFunction TileLoadFunction.
|
* @property {import("../Tile.js").LoadFunction} tileLoadFunction TileLoadFunction.
|
||||||
* @property {number} [tilePixelRatio] TilePixelRatio.
|
* @property {number} [tilePixelRatio] TilePixelRatio.
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import EventType from '../events/EventType.js';
|
|||||||
import ObjectEventType from '../ObjectEventType.js';
|
import ObjectEventType from '../ObjectEventType.js';
|
||||||
import RBush from '../structs/RBush.js';
|
import RBush from '../structs/RBush.js';
|
||||||
import Source from './Source.js';
|
import Source from './Source.js';
|
||||||
import SourceState from './State.js';
|
|
||||||
import VectorEventType from './VectorEventType.js';
|
import VectorEventType from './VectorEventType.js';
|
||||||
import {TRUE, VOID} from '../functions.js';
|
import {TRUE, VOID} from '../functions.js';
|
||||||
import {all as allStrategy} from '../loadingstrategy.js';
|
import {all as allStrategy} from '../loadingstrategy.js';
|
||||||
@@ -183,7 +182,7 @@ class VectorSource extends Source {
|
|||||||
attributions: options.attributions,
|
attributions: options.attributions,
|
||||||
interpolate: true,
|
interpolate: true,
|
||||||
projection: undefined,
|
projection: undefined,
|
||||||
state: SourceState.READY,
|
state: 'ready',
|
||||||
wrapX: options.wrapX !== undefined ? options.wrapX : true,
|
wrapX: options.wrapX !== undefined ? options.wrapX : true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import {toSize} from '../size.js';
|
|||||||
* boundaries or TopoJSON sources) allows the renderer to optimise fill and
|
* boundaries or TopoJSON sources) allows the renderer to optimise fill and
|
||||||
* stroke operations.
|
* stroke operations.
|
||||||
* @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Projection of the tile grid.
|
* @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Projection of the tile grid.
|
||||||
* @property {import("./State.js").default} [state] Source state.
|
* @property {import("./Source.js").State} [state] Source state.
|
||||||
* @property {typeof import("../VectorTile.js").default} [tileClass] Class used to instantiate image tiles.
|
* @property {typeof import("../VectorTile.js").default} [tileClass] Class used to instantiate image tiles.
|
||||||
* Default is {@link module:ol/VectorTile~VectorTile}.
|
* Default is {@link module:ol/VectorTile~VectorTile}.
|
||||||
* @property {number} [maxZoom=22] Optional max zoom level. Not used if `tileGrid` is provided.
|
* @property {number} [maxZoom=22] Optional max zoom level. Not used if `tileGrid` is provided.
|
||||||
|
|||||||
Reference in New Issue
Block a user